|
from handler import EndpointHandler
|
|
import json
|
|
from typing import List
|
|
import requests as r
|
|
import base64
|
|
import requests as r
|
|
import base64
|
|
from PIL import Image
|
|
from io import BytesIO
|
|
|
|
ENDPOINT_URL = ""
|
|
HF_TOKEN = ""
|
|
def decode_base64_image(image_string):
|
|
base64_image = base64.b64decode(image_string)
|
|
buffer = BytesIO(base64_image)
|
|
return Image.open(buffer)
|
|
|
|
|
|
my_handler = EndpointHandler(path=".")
|
|
|
|
|
|
path_to_image = "test_images/lal.jpg"
|
|
with open(path_to_image, "rb") as i:
|
|
b64 = base64.b64encode(i.read())
|
|
|
|
payload = {"inputs": {"image": b64.decode("utf-8"), "class_text": "shirt", "prompt": "wedding shirt"}}
|
|
|
|
|
|
results=my_handler(payload)
|
|
|
|
|
|
|
|
|
|
decode_base64_image(results["image"]).save("test_results.jpg")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|