hasanbasbunar commited on
Commit
01ac878
·
verified ·
1 Parent(s): f734da8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -216,7 +216,13 @@ def chat_respond(message, history, chat_state, img_input, model_ui, grounding):
216
  file_path = os.path.join(TEMP_CHAT_DIR, unique_filename)
217
  img.save(file_path)
218
 
219
- bot_messages.append({"role": "assistant", "content": (file_path, "Generated Image")})
 
 
 
 
 
 
220
 
221
  # D. Empty response handling
222
  if not f_txt and not f_imgs and not t_txt:
@@ -353,8 +359,7 @@ with gr.Blocks(title="Nano Vision Studio") as demo:
353
 
354
  with gr.Row():
355
  chat_input = gr.Textbox(label="Your Message", placeholder="e.g., 'Generate a portrait', then 'Add glasses'...", scale=4)
356
- chat_img = gr.Image(label="Input Image (Optional)", type="filepath", height=100, scale=1, container=False)
357
-
358
  with gr.Row():
359
  chat_btn = gr.Button("Send", variant="primary")
360
  clear_btn = gr.Button("🗑️ New Session")
@@ -407,4 +412,13 @@ with gr.Blocks(title="Nano Vision Studio") as demo:
407
  """)
408
 
409
  if __name__ == "__main__":
410
- demo.launch(theme=gr.themes.Soft(), css=css)
 
 
 
 
 
 
 
 
 
 
216
  file_path = os.path.join(TEMP_CHAT_DIR, unique_filename)
217
  img.save(file_path)
218
 
219
+ # bot_messages.append({"role": "assistant", "content": (file_path, "Generated Image")})
220
+ # CORRECTION : On crée un dictionnaire
221
+ img_msg = {
222
+ "path": file_path,
223
+ "alt_text": "Generated Image"
224
+ }
225
+ bot_messages.append({"role": "assistant", "content": img_msg})
226
 
227
  # D. Empty response handling
228
  if not f_txt and not f_imgs and not t_txt:
 
359
 
360
  with gr.Row():
361
  chat_input = gr.Textbox(label="Your Message", placeholder="e.g., 'Generate a portrait', then 'Add glasses'...", scale=4)
362
+ chat_img = gr.Image(label="Input Image (Optional)", type="filepath", height=100)
 
363
  with gr.Row():
364
  chat_btn = gr.Button("Send", variant="primary")
365
  clear_btn = gr.Button("🗑️ New Session")
 
412
  """)
413
 
414
  if __name__ == "__main__":
415
+ # Configuration Gradio 6.0
416
+ demo.queue(default_concurrency_limit=20)
417
+
418
+ # Le thème et le CSS se mettent ICI maintenant
419
+ demo.launch(
420
+ theme=gr.themes.Soft(),
421
+ css=css,
422
+ max_threads=40,
423
+ show_error=True
424
+ )