Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,8 @@ import gradio as gr
|
|
5 |
from datetime import datetime
|
6 |
import agent
|
7 |
from models import models
|
8 |
-
import
|
|
|
9 |
import uuid
|
10 |
base_url="https://johann22-chat-diffusion.hf.space/"
|
11 |
|
@@ -54,30 +55,39 @@ def run_gpt(in_prompt,history):
|
|
54 |
|
55 |
|
56 |
def run(purpose,history,model_drop):
|
|
|
|
|
|
|
|
|
|
|
57 |
if history:
|
58 |
history=str(history).strip("[]")
|
59 |
if not history:
|
60 |
history = ""
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
yield ("",[(purpose,out_prompt)],None)
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
#return ("", [(purpose,history)])
|
80 |
-
|
81 |
|
82 |
|
83 |
|
|
|
5 |
from datetime import datetime
|
6 |
import agent
|
7 |
from models import models
|
8 |
+
import requests
|
9 |
+
import io
|
10 |
import uuid
|
11 |
base_url="https://johann22-chat-diffusion.hf.space/"
|
12 |
|
|
|
55 |
|
56 |
|
57 |
def run(purpose,history,model_drop):
|
58 |
+
|
59 |
+
#print(purpose)
|
60 |
+
#print(hist)
|
61 |
+
task=None
|
62 |
+
directory="./"
|
63 |
if history:
|
64 |
history=str(history).strip("[]")
|
65 |
if not history:
|
66 |
history = ""
|
67 |
+
|
68 |
+
#action_name, action_input = parse_action(line)
|
69 |
+
out_prompt = run_gpt(
|
70 |
+
purpose,
|
71 |
+
history,
|
72 |
+
|
73 |
+
)
|
74 |
+
|
75 |
yield ("",[(purpose,out_prompt)],None)
|
76 |
+
#out_img = infer(out_prompt)
|
77 |
+
model=loaded_model[int(model_drop)]
|
78 |
+
out_img=model(out_prompt)
|
79 |
+
print(out_img)
|
80 |
+
url=f'https://johann22-chat-diffusion.hf.space/file={out_img}'
|
81 |
+
print(url)
|
82 |
+
uid = uuid.uuid4()
|
83 |
+
#urllib.request.urlretrieve(image, 'tmp.png')
|
84 |
+
#out=Image.open('tmp.png')
|
85 |
+
r = requests.get(url, stream=True)
|
86 |
+
if r.status_code == 200:
|
87 |
+
out = Image.open(io.BytesIO(r.content))
|
88 |
+
yield ("",[(purpose,out_prompt)],out)
|
89 |
#return ("", [(purpose,history)])
|
90 |
+
|
91 |
|
92 |
|
93 |
|