Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,12 +24,14 @@ def run_vlm(image, prompt):
|
|
| 24 |
return processor.decode(out[0], skip_special_tokens=True)
|
| 25 |
# return f"Model output for: '{prompt}' and selected image."
|
| 26 |
|
| 27 |
-
def get_random_image(event):
|
| 28 |
-
jpgs = [f for f in os.listdir(
|
| 29 |
if not jpgs:
|
| 30 |
-
return STATIC_IMAGE_PATH, STATIC_IMAGE_PATH
|
|
|
|
| 31 |
selected = os.path.join(IMAGE_FOLDER, random.choice(jpgs))
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
|
|
@@ -50,7 +52,7 @@ with gr.Blocks() as demo:
|
|
| 50 |
|
| 51 |
output = gr.Textbox(label="Model Output")
|
| 52 |
|
| 53 |
-
random_button.click(fn=get_random_image, outputs=image_display)
|
| 54 |
run_button.click(fn=process, inputs=[image_path, user_prompt], outputs=output)
|
| 55 |
|
| 56 |
# with gr.Blocks() as demo:
|
|
|
|
| 24 |
return processor.decode(out[0], skip_special_tokens=True)
|
| 25 |
# return f"Model output for: '{prompt}' and selected image."
|
| 26 |
|
| 27 |
+
def get_random_image(event=None):
|
| 28 |
+
jpgs = [f for f in os.listdir(image_dir) if f.endswith(".jpg")]
|
| 29 |
if not jpgs:
|
| 30 |
+
return gr.update(value=STATIC_IMAGE_PATH), gr.update(value=STATIC_IMAGE_PATH)
|
| 31 |
+
|
| 32 |
selected = os.path.join(IMAGE_FOLDER, random.choice(jpgs))
|
| 33 |
+
print(selected)
|
| 34 |
+
return gr.update(value=selected), gr.update(value=selected)
|
| 35 |
|
| 36 |
|
| 37 |
|
|
|
|
| 52 |
|
| 53 |
output = gr.Textbox(label="Model Output")
|
| 54 |
|
| 55 |
+
random_button.click(fn=get_random_image, outputs=[image_display, image_path])
|
| 56 |
run_button.click(fn=process, inputs=[image_path, user_prompt], outputs=output)
|
| 57 |
|
| 58 |
# with gr.Blocks() as demo:
|