Emmanuel Frimpong Asante
commited on
Commit
·
b017f70
1
Parent(s):
717d87a
"Update space"
Browse filesSigned-off-by: Emmanuel Frimpong Asante <[email protected]>
app.py
CHANGED
@@ -62,16 +62,23 @@ def combined_interface(image, text):
|
|
62 |
return "Please provide an image or ask a question."
|
63 |
|
64 |
|
65 |
-
|
|
|
|
|
|
|
66 |
if not os.path.isfile(example_image_path):
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
|
69 |
# Create Gradio interface
|
70 |
interface = gr.Interface(
|
71 |
fn=combined_interface,
|
72 |
inputs=[gr.Image(label='Upload Image'), gr.Textbox(label='Ask a question')],
|
73 |
outputs=gr.Textbox(label="Response"),
|
74 |
-
examples=
|
75 |
)
|
76 |
|
77 |
# Launch the interface
|
|
|
62 |
return "Please provide an image or ask a question."
|
63 |
|
64 |
|
65 |
+
# Ensure the example file paths are correct and point to actual files
|
66 |
+
example_image_path = '/home/user/app/disease.jpg' # Replace with actual file path
|
67 |
+
|
68 |
+
# Check if the example image exists and is a file
|
69 |
if not os.path.isfile(example_image_path):
|
70 |
+
print(f"Warning: Example image file not found: {example_image_path}")
|
71 |
+
example_image_path = None # Disable the example
|
72 |
+
|
73 |
+
# Only include the example if the path is valid
|
74 |
+
examples = [[example_image_path, ''], ['', 'What should I do if my chicken is sick?']] if example_image_path else None
|
75 |
|
76 |
# Create Gradio interface
|
77 |
interface = gr.Interface(
|
78 |
fn=combined_interface,
|
79 |
inputs=[gr.Image(label='Upload Image'), gr.Textbox(label='Ask a question')],
|
80 |
outputs=gr.Textbox(label="Response"),
|
81 |
+
examples=examples # Use examples only if valid
|
82 |
)
|
83 |
|
84 |
# Launch the interface
|