Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI | |
| import base64 | |
| from gradio_client import Client, handle_file | |
| app=FastAPI() | |
| def Runn(): | |
| client = Client("bytedance-research/UNO-FLUX") | |
| result = client.predict( | |
| prompt="an orange cat in the field", | |
| width=512, | |
| height=512, | |
| guidance=4, | |
| num_steps=25, | |
| seed=-1, | |
| image_prompt1=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'), | |
| image_prompt2=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'), | |
| image_prompt3=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'), | |
| image_prompt4=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'), | |
| api_name="/gradio_generate" | |
| ) | |
| preview_path, final_image_path = result | |
| # Read and encode as base64 | |
| with open(final_image_path, 'rb') as f: | |
| image_data = base64.b64encode(f.read()).decode('utf-8') | |
| return { | |
| "image": f"data:image/png;base64,{image_data}", | |
| "preview": preview_path # or convert this too | |
| } | |
| def SS(): | |
| boom=Runn() | |
| return boom | |