Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,6 +31,7 @@ history = []
|
|
31 |
|
32 |
def gen_from_infer(purpose,history,image,model_drop,chat_drop,choice):
|
33 |
#out_img = infer(out_prompt)
|
|
|
34 |
out_prompt=generate(purpose,history,chat_drop)
|
35 |
history.append((purpose,out_prompt))
|
36 |
yield (history,None)
|
@@ -38,33 +39,19 @@ def gen_from_infer(purpose,history,image,model_drop,chat_drop,choice):
|
|
38 |
print (infer_model)
|
39 |
infer=InferenceClient(f'{infer_model}')
|
40 |
print (infer)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
51 |
yield (history,out_img)
|
52 |
-
|
53 |
-
#return (history,None)
|
54 |
-
print(out_img)
|
55 |
-
url=f'https://johann22-chat-diffusion-describe.hf.space/file={out_img}'
|
56 |
-
print(url)
|
57 |
-
uid = uuid.uuid4()
|
58 |
-
#urllib.request.urlretrieve(image, 'tmp.png')
|
59 |
-
#out=Image.open('tmp.png')
|
60 |
-
r = requests.get(url, stream=True)
|
61 |
-
if r.status_code == 200:
|
62 |
-
out = Image.open(io.BytesIO(r.content))
|
63 |
-
#yield ([(purpose,out_prompt)],out)
|
64 |
-
yield (history,out)
|
65 |
-
else:
|
66 |
-
yield ([(purpose,"an Error occured")],None)
|
67 |
-
'''
|
68 |
def format_prompt(message, history):
|
69 |
prompt = "<s>"
|
70 |
for user_prompt, bot_response in history:
|
|
|
31 |
|
32 |
def gen_from_infer(purpose,history,image,model_drop,chat_drop,choice):
|
33 |
#out_img = infer(out_prompt)
|
34 |
+
history = ""
|
35 |
out_prompt=generate(purpose,history,chat_drop)
|
36 |
history.append((purpose,out_prompt))
|
37 |
yield (history,None)
|
|
|
39 |
print (infer_model)
|
40 |
infer=InferenceClient(f'{infer_model}')
|
41 |
print (infer)
|
42 |
+
|
43 |
+
out_img=infer.text_to_image(
|
44 |
+
prompt=out_prompt,
|
45 |
+
negative_prompt=None,
|
46 |
+
height=512,
|
47 |
+
width=512,
|
48 |
+
num_inference_steps=None,
|
49 |
+
guidance_scale=None,
|
50 |
+
model=None,
|
51 |
+
seed=1,
|
52 |
+
)
|
53 |
yield (history,out_img)
|
54 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
def format_prompt(message, history):
|
56 |
prompt = "<s>"
|
57 |
for user_prompt, bot_response in history:
|