Workpam commited on
Commit
6178eb1
·
verified ·
1 Parent(s): 9cbf52e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -16
app.py CHANGED
@@ -60,26 +60,17 @@ with gr.Blocks(title="Qwen2.5-VL-7B via Inference API") as demo:
60
  show_copy_button=True
61
  )
62
 
63
- # Show image previews
64
  file_input.change(
65
- fn=lambda files: [f.read() and None or None for f in (files or [])],
66
  inputs=file_input,
67
- outputs=gallery,
68
- preprocess=False
69
  )
70
 
71
  # Generate captions
72
- generate_btn.click(
73
- fn=generate_alt_text,
74
- inputs=[file_input, max_new_tokens],
75
- outputs=output,
76
- queue=True
77
- )
78
 
79
- # Clear all
80
- clear_btn.click(
81
- fn=lambda: ([], 128, [], ""),
82
- outputs=[file_input, max_new_tokens, gallery, output]
83
- )
84
 
85
- demo.launch()
 
60
  show_copy_button=True
61
  )
62
 
63
+ # Show image previews in the gallery when images are selected
64
  file_input.change(
65
+ fn=lambda files: [f["name"] for f in (files or [])],
66
  inputs=file_input,
67
+ outputs=gallery
 
68
  )
69
 
70
  # Generate captions
71
+ generate_btn.click(generate_alt_text, [file_input, max_new_tokens], output, queue=True)
 
 
 
 
 
72
 
73
+ # Clear all fields
74
+ clear_btn.click(lambda: ([], 128, [], ""), outputs=[file_input, max_new_tokens, gallery, output])
 
 
 
75
 
76
+ demo.launch()()