Spaces:
Sleeping
Sleeping
Download src/data/request_images.py from VelaTest/Look-A-Like_Image-Finder: direct link, hf CLI and curl.
- Browser
- Download file 758 Bytes
-
https://huggingface.co/spaces/VelaTest/Look-A-Like_Image-Finder/resolve/main/src/data/request_images.py
- Command line
-
hf download hf://spaces/VelaTest/Look-A-Like_Image-Finder/src/data/request_images.py
-
curl -L -o request_images.py https://huggingface.co/spaces/VelaTest/Look-A-Like_Image-Finder/resolve/main/src/data/request_images.py
758 Bytes
| import requests | |
| from PIL import Image | |
| from utils import logger | |
| logger = logger.get_logger() | |
| def get_image_url(url): | |
| try: | |
| logger.info("Loading image from url to embed") | |
| res = requests.get(url,stream = True).raw | |
| img = Image.open(res) | |
| logger.info("Loaded the image to embed successfully") | |
| return img | |
| except Exception as e: | |
| logger.error(f"Unable to load the image to embed {e}") | |
| def convert_image_to_embedding_format(query_image): | |
| try: | |
| logger.info("Loading the image to embed") | |
| image = Image.open(query_image) | |
| logger.info("Loaded the image to embed successfully") | |
| return image | |
| except Exception as e: | |
| logger.error(f"Unable to load the image to embed {e}") | |