Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -22,18 +22,8 @@ date_time_str = now.strftime("%Y-%m-%d %H:%M:%S")
|
|
22 |
client = InferenceClient(
|
23 |
"mistralai/Mixtral-8x7B-Instruct-v0.1"
|
24 |
)
|
25 |
-
|
26 |
-
############################################
|
27 |
-
model = gr.load("models/stabilityai/sdxl-turbo")
|
28 |
-
|
29 |
-
VERBOSE = True
|
30 |
-
MAX_HISTORY = 10000
|
31 |
-
#MODEL = "gpt-3.5-turbo" # "gpt-4"
|
32 |
history = []
|
33 |
|
34 |
-
def infer(txt):
|
35 |
-
return (model(txt))
|
36 |
-
|
37 |
def format_prompt(message, history):
|
38 |
prompt = "<s>"
|
39 |
for user_prompt, bot_response in history:
|
@@ -81,7 +71,6 @@ def run(purpose,history,model_drop):
|
|
81 |
#print(purpose)
|
82 |
#print(hist)
|
83 |
task=None
|
84 |
-
directory="./"
|
85 |
#if history:
|
86 |
# history=str(history).strip("[]")
|
87 |
#if not history:
|
@@ -94,7 +83,7 @@ def run(purpose,history,model_drop):
|
|
94 |
|
95 |
)
|
96 |
|
97 |
-
yield (
|
98 |
#out_img = infer(out_prompt)
|
99 |
model=loaded_model[int(model_drop)]
|
100 |
out_img=model(out_prompt)
|
@@ -107,8 +96,8 @@ def run(purpose,history,model_drop):
|
|
107 |
r = requests.get(url, stream=True)
|
108 |
if r.status_code == 200:
|
109 |
out = Image.open(io.BytesIO(r.content))
|
110 |
-
yield (
|
111 |
-
#return (
|
112 |
|
113 |
|
114 |
|
@@ -118,20 +107,20 @@ with gr.Blocks() as iface:
|
|
118 |
gr.HTML("""<center><h1>Chat Diffusion</h1><br><h3>This chatbot will generate images</h3></center>""")
|
119 |
#chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
120 |
with gr.Row():
|
121 |
-
with gr.Column():
|
122 |
chatbot=gr.Chatbot()
|
123 |
msg = gr.Textbox()
|
124 |
model_drop=gr.Dropdown(label="Diffusion Models", type="index", choices=[m for m in models], value=models[0])
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
|
133 |
-
sub_b = submit_b.click(run, [msg,chatbot,model_drop],[
|
134 |
-
sub_e = msg.submit(run, [msg, chatbot,model_drop], [
|
135 |
stop_b.click(None,None,None, cancels=[sub_b,sub_e])
|
136 |
iface.launch()
|
137 |
'''
|
|
|
22 |
client = InferenceClient(
|
23 |
"mistralai/Mixtral-8x7B-Instruct-v0.1"
|
24 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
history = []
|
26 |
|
|
|
|
|
|
|
27 |
def format_prompt(message, history):
|
28 |
prompt = "<s>"
|
29 |
for user_prompt, bot_response in history:
|
|
|
71 |
#print(purpose)
|
72 |
#print(hist)
|
73 |
task=None
|
|
|
74 |
#if history:
|
75 |
# history=str(history).strip("[]")
|
76 |
#if not history:
|
|
|
83 |
|
84 |
)
|
85 |
|
86 |
+
yield ([(purpose,out_prompt)],None)
|
87 |
#out_img = infer(out_prompt)
|
88 |
model=loaded_model[int(model_drop)]
|
89 |
out_img=model(out_prompt)
|
|
|
96 |
r = requests.get(url, stream=True)
|
97 |
if r.status_code == 200:
|
98 |
out = Image.open(io.BytesIO(r.content))
|
99 |
+
yield ([(purpose,out_prompt)],out)
|
100 |
+
#return ([(purpose,history)])
|
101 |
|
102 |
|
103 |
|
|
|
107 |
gr.HTML("""<center><h1>Chat Diffusion</h1><br><h3>This chatbot will generate images</h3></center>""")
|
108 |
#chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
|
109 |
with gr.Row():
|
110 |
+
with gr.Column(scale=1):
|
111 |
chatbot=gr.Chatbot()
|
112 |
msg = gr.Textbox()
|
113 |
model_drop=gr.Dropdown(label="Diffusion Models", type="index", choices=[m for m in models], value=models[0])
|
114 |
+
with gr.Group():
|
115 |
+
submit_b = gr.Button()
|
116 |
+
with gr.Row():
|
117 |
+
stop_b = gr.Button("Stop")
|
118 |
+
clear = gr.ClearButton([msg, chatbot])
|
119 |
+
with gr.Column(scale=2):
|
120 |
+
im_out=gr.Image(label="Image")
|
121 |
|
122 |
+
sub_b = submit_b.click(run, [msg,chatbot,model_drop],[chatbot,im_out])
|
123 |
+
sub_e = msg.submit(run, [msg, chatbot,model_drop], [chatbot,im_out])
|
124 |
stop_b.click(None,None,None, cancels=[sub_b,sub_e])
|
125 |
iface.launch()
|
126 |
'''
|