File size: 758 Bytes
0930d33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5427e5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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}")