import fal_client from src.utils import numpy_to_base64 from src.helpers import resize_image def fal_ipadapter_api(input_image,ip_image,seg_prompt): print(input_image,ip_image,seg_prompt) handler = fal_client.submit( "comfy/JarvisSan22/cloth_ipadapter", arguments={ "loadimage_1":numpy_to_base64(input_image), "loadimage_2":numpy_to_base64(ip_image), "groundingdinosamsegment (segment anything)_prompt":seg_prompt }, ) print(handler) result= handler.get() #image_urls=[] print(result["outputs"]) """ for k,item in result["outputs"].items(): if "images" in item: image_urls.append(item["images"][0]["url"]) print(image_urls) return image_urls """ #print(result) return result["outputs"]["20"]["images"][0]["url"] def fal_faceswap_api(input_image,face_image): print(input_image.shape,face_image.shape,type(face_image)) #face_image.resize((1024, 1024)) input_image=resize_image(input_image) face_image=resize_image(face_image) print(input_image.shape,face_image.shape) handler = fal_client.submit( "fal-ai/face-swap", arguments={ "base_image_url": numpy_to_base64(input_image), "swap_image_url": numpy_to_base64(face_image), }, ) result = handler.get() print(result) return result["image"]["url"]