Junaidb commited on
Commit
9a63fef
·
verified ·
1 Parent(s): ec4a51f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import base64
3
+ from gradio_client import Client, handle_file
4
+
5
+ app=FastAPI()
6
+
7
+
8
+
9
+ def Runn():
10
+ client = Client("bytedance-research/UNO-FLUX")
11
+ result = client.predict(
12
+ prompt="an orange cat in the field",
13
+ width=512,
14
+ height=512,
15
+ guidance=4,
16
+ num_steps=25,
17
+ seed=-1,
18
+ image_prompt1=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
19
+ image_prompt2=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
20
+ image_prompt3=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
21
+ image_prompt4=handle_file('https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png'),
22
+ api_name="/gradio_generate"
23
+ )
24
+
25
+ preview_path, final_image_path = result
26
+
27
+ # Read and encode as base64
28
+ with open(final_image_path, 'rb') as f:
29
+ image_data = base64.b64encode(f.read()).decode('utf-8')
30
+
31
+ return {
32
+ "image": f"data:image/png;base64,{image_data}",
33
+ "preview": preview_path # or convert this too
34
+ }
35
+
36
+
37
+ @app.get("/ss")
38
+ def SS():
39
+ boom=Runn()
40
+ return boom