Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,13 +16,30 @@ for i,model in enumerate(models):
|
|
16 |
pass
|
17 |
print (loaded_model)
|
18 |
|
19 |
-
def run_dif(out_prompt):
|
20 |
out_box=[]
|
21 |
out_html=""
|
22 |
-
for i,ea in enumerate(loaded_model):
|
|
|
23 |
try:
|
24 |
-
|
25 |
-
model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
out_img=model(out_prompt)
|
27 |
print(out_img)
|
28 |
url=f'https://omnibus-top-20.hf.space/file={out_img}'
|
@@ -69,13 +86,17 @@ def thread_dif(out_prompt,mod):
|
|
69 |
print (f'bytes:: {io.BytesIO(r.content)}')
|
70 |
str_equivalent_image = base64.b64encode(img_buffer.getvalue()).decode()
|
71 |
img_tag = "<img src='data:image/png;base64," + str_equivalent_image + "'/>"
|
72 |
-
|
|
|
73 |
out = Image.open(io.BytesIO(r.content))
|
74 |
out_box.append(out)
|
|
|
|
|
75 |
html_out = "<div class='grid_class'>"+out_html+"</div>"
|
76 |
return out_box,html_out
|
77 |
except Exception as e:
|
78 |
-
out_html
|
|
|
79 |
html_out = "<div class='grid_class'>"+out_html+"</div>"
|
80 |
|
81 |
return out_box,html_out
|
@@ -104,9 +125,14 @@ min-width:200px;
|
|
104 |
|
105 |
"""
|
106 |
with gr.Blocks(css=css) as app:
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
out_html=gr.HTML()
|
109 |
outp=gr.Gallery()
|
110 |
-
btn
|
111 |
-
btn.click(run_dif,inp,[outp,out_html])
|
112 |
app.launch()
|
|
|
16 |
pass
|
17 |
print (loaded_model)
|
18 |
|
19 |
+
def run_dif(out_prompt,model_drop,cnt):
|
20 |
out_box=[]
|
21 |
out_html=""
|
22 |
+
#for i,ea in enumerate(loaded_model):
|
23 |
+
for i in range(cnt):
|
24 |
try:
|
25 |
+
model=loaded_model[int(model_drop)]
|
26 |
+
out_img=model(out_prompt)
|
27 |
+
print(out_img)
|
28 |
+
out_box.append(out_img)
|
29 |
+
except Exception as e:
|
30 |
+
print(e)
|
31 |
+
out_html=str(e)
|
32 |
+
pass
|
33 |
+
yield out_box,out_html
|
34 |
+
|
35 |
+
def run_dif_og(out_prompt,model_drop,cnt):
|
36 |
+
out_box=[]
|
37 |
+
out_html=""
|
38 |
+
#for i,ea in enumerate(loaded_model):
|
39 |
+
for i in range(cnt):
|
40 |
+
try:
|
41 |
+
#print (ea)
|
42 |
+
model=loaded_model[int(model_drop)]
|
43 |
out_img=model(out_prompt)
|
44 |
print(out_img)
|
45 |
url=f'https://omnibus-top-20.hf.space/file={out_img}'
|
|
|
86 |
print (f'bytes:: {io.BytesIO(r.content)}')
|
87 |
str_equivalent_image = base64.b64encode(img_buffer.getvalue()).decode()
|
88 |
img_tag = "<img src='data:image/png;base64," + str_equivalent_image + "'/>"
|
89 |
+
|
90 |
+
#out_html+=f"<div class='img_class'><a href='https://huggingface.co/models/{models[i]}'>{models[i]}</a><br>"+img_tag+"</div>"
|
91 |
out = Image.open(io.BytesIO(r.content))
|
92 |
out_box.append(out)
|
93 |
+
else:
|
94 |
+
out_html=r.status_code
|
95 |
html_out = "<div class='grid_class'>"+out_html+"</div>"
|
96 |
return out_box,html_out
|
97 |
except Exception as e:
|
98 |
+
out_html=str(e)
|
99 |
+
#out_html+=str(e)
|
100 |
html_out = "<div class='grid_class'>"+out_html+"</div>"
|
101 |
|
102 |
return out_box,html_out
|
|
|
125 |
|
126 |
"""
|
127 |
with gr.Blocks(css=css) as app:
|
128 |
+
with gr.Row():
|
129 |
+
inp=gr.Textbox(label="Prompt")
|
130 |
+
btn=gr.Button()
|
131 |
+
|
132 |
+
with gr.Row():
|
133 |
+
model_drop=gr.Dropdown(label="Models", choices=models, type=index, value=models[0])
|
134 |
+
cnt = gr.Number()
|
135 |
out_html=gr.HTML()
|
136 |
outp=gr.Gallery()
|
137 |
+
btn.click(run_dif,[inp,model_drop,cnt],[outp,out_html])
|
|
|
138 |
app.launch()
|