Upload handler.py
Browse files5 unmodified lines67891011121360 unmodified lines7475767778798081828384858687885 unmodified linesfrom ultralytics import YOLOimport osimport gdownfrom PIL import Imageimport io
class EndpointHandler: def __init__(self, path='.'): # pass api key to model60 unmodified lines cv2.imwrite("result.jpg", clothes) # create base 64 object jpg_as_text = base64.b64encode(buffer).decode("utf-8") # Decode bytes to string") # base64_encoded = base64.b64encode(image_bytes).decode("utf-8") # Get the image format image_format = Image.open(io.BytesIO(buffer)).format.lower() # Construct the data URI data_uri = f"data:image/{image_format};base64,{jpg_as_text}" return data_uri print("checkpoint 4")########################################################################### return jpg_as_texthandler.py+11