jrfish commited on
Commit
37171a1
·
verified ·
1 Parent(s): 40fedaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -26,7 +26,8 @@ def run_vlm(image, prompt):
26
 
27
  def random_image():
28
  path = random.choice(images)
29
- return path # Also return path if needed for model input
 
30
 
31
  def process(image_path, user_prompt):
32
  image = Image.open(image_path)
@@ -37,11 +38,13 @@ with gr.Blocks() as demo:
37
  image_display = gr.Image(type="filepath", label="Selected Image")
38
  random_button = gr.Button("Randomize Photo")
39
 
 
40
  user_prompt = gr.Textbox(label="User Prompt")
41
  run_button = gr.Button("Run Model")
42
  output = gr.Textbox(label="Model Output")
43
 
44
- random_button.click(fn=random_image, outputs=image_display)
45
- run_button.click(fn=process, inputs=[image_display, user_prompt], outputs=output)
 
46
 
47
  demo.launch()
 
26
 
27
  def random_image():
28
  path = random.choice(images)
29
+ return Image.open(path), path
30
+
31
 
32
  def process(image_path, user_prompt):
33
  image = Image.open(image_path)
 
38
  image_display = gr.Image(type="filepath", label="Selected Image")
39
  random_button = gr.Button("Randomize Photo")
40
 
41
+ image_path = gr.Textbox(visible=False)
42
  user_prompt = gr.Textbox(label="User Prompt")
43
  run_button = gr.Button("Run Model")
44
  output = gr.Textbox(label="Model Output")
45
 
46
+ random_button.click(fn=random_image, outputs=[image_display, image_path])
47
+ run_button.click(fn=process, inputs=[image_path, user_prompt], outputs=output)
48
+
49
 
50
  demo.launch()