Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,39 @@
|
|
1 |
import gradio as gr
|
2 |
from models import models
|
|
|
|
|
|
|
|
|
3 |
loaded_model=[]
|
4 |
for i,model in enumerate(models):
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
print (loaded_model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from models import models
|
3 |
+
import requests
|
4 |
+
import uuid
|
5 |
+
import io
|
6 |
+
|
7 |
loaded_model=[]
|
8 |
for i,model in enumerate(models):
|
9 |
+
try:
|
10 |
+
loaded_model.append(gr.load(f'models/{model}'))
|
11 |
+
except Exception as e:
|
12 |
+
print(e)
|
13 |
+
pass
|
14 |
print (loaded_model)
|
15 |
+
|
16 |
+
def run_dif(out_prompt):
|
17 |
+
out_box=[]
|
18 |
+
for i,ea in enumerate(loaded_model):
|
19 |
+
print (ea)
|
20 |
+
model=loaded_model[int(i)]
|
21 |
+
out_img=model(out_prompt)
|
22 |
+
print(out_img)
|
23 |
+
url=f'https://omnibus-top-20.hf.space/file={out_img}'
|
24 |
+
print(url)
|
25 |
+
uid = uuid.uuid4()
|
26 |
+
#urllib.request.urlretrieve(image, 'tmp.png')
|
27 |
+
#out=Image.open('tmp.png')
|
28 |
+
r = requests.get(url, stream=True)
|
29 |
+
if r.status_code == 200:
|
30 |
+
out = Image.open(io.BytesIO(r.content))
|
31 |
+
out_box.append(out)
|
32 |
+
yield out_box
|
33 |
+
|
34 |
+
with gr.Blocks() as app:
|
35 |
+
inp=gr.Textbox()
|
36 |
+
outp=gr.Gallery()
|
37 |
+
btn=gr.Button()
|
38 |
+
btn.click(run_dif,inp,outp)
|
39 |
+
app.launch()
|