Spaces:
Build error
Build error
updated image pipe
Browse files
app.py
CHANGED
@@ -85,7 +85,22 @@ def image_analyzer(image_url: str):
|
|
85 |
)
|
86 |
logging.info("--- Image Analyzer pipeline initialized. ---")
|
87 |
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
return description
|
90 |
except Exception as e:
|
91 |
logging.error(f"Error analyzing image: {e}")
|
@@ -374,8 +389,7 @@ with gr.Blocks() as demo:
|
|
374 |
3. Click 'Run Evaluation & Submit All Answers' to fetch the questions, run the agent, submit the answers, and see your score.
|
375 |
---
|
376 |
**Disclaimer:**
|
377 |
-
- Once you click the submit button, please be patient.
|
378 |
-
The agent needs time to process all the questions, which can take several minutes depending on the model and hardware.
|
379 |
"""
|
380 |
)
|
381 |
|
|
|
85 |
)
|
86 |
logging.info("--- Image Analyzer pipeline initialized. ---")
|
87 |
|
88 |
+
# More robustly handle the pipeline output
|
89 |
+
pipeline_output = image_to_text_pipeline(image_url)
|
90 |
+
if (
|
91 |
+
pipeline_output
|
92 |
+
and isinstance(pipeline_output, list)
|
93 |
+
and len(pipeline_output) > 0
|
94 |
+
):
|
95 |
+
description = pipeline_output[0].get(
|
96 |
+
"generated_text", "Error: Could not find text in image analysis result."
|
97 |
+
)
|
98 |
+
else:
|
99 |
+
logging.error(
|
100 |
+
f"Image analyzer returned no or invalid output for URL: {image_url}"
|
101 |
+
)
|
102 |
+
description = "Error: Could not analyze image."
|
103 |
+
|
104 |
return description
|
105 |
except Exception as e:
|
106 |
logging.error(f"Error analyzing image: {e}")
|
|
|
389 |
3. Click 'Run Evaluation & Submit All Answers' to fetch the questions, run the agent, submit the answers, and see your score.
|
390 |
---
|
391 |
**Disclaimer:**
|
392 |
+
- Once you click the submit button, please be patient. The agent needs time to process all the questions, which can take several minutes depending on the model and hardware.
|
|
|
393 |
"""
|
394 |
)
|
395 |
|