Update app.py
Browse files
app.py
CHANGED
|
@@ -148,7 +148,7 @@ def process_and_analyze_image(image):
|
|
| 148 |
analyzer = SAMAnalyzer(model_path=MODEL_PATH)
|
| 149 |
|
| 150 |
print("Processing image...")
|
| 151 |
-
veg_index, health_analysis,
|
| 152 |
|
| 153 |
if veg_index is None:
|
| 154 |
return None, "Error processing image.", "Image processing failed"
|
|
@@ -164,12 +164,10 @@ def process_and_analyze_image(image):
|
|
| 164 |
• High Vegetation: {health_analysis['health_distribution']['high_vegetation']*100:.1f}%
|
| 165 |
|
| 166 |
📋 Overall Health Status: {health_analysis['overall_health']}
|
| 167 |
-
|
| 168 |
-
Note: Analysis uses SAM2 for farmland segmentation
|
| 169 |
"""
|
| 170 |
|
| 171 |
debug_msg = "Analysis completed successfully"
|
| 172 |
-
return
|
| 173 |
|
| 174 |
except Exception as e:
|
| 175 |
error_msg = f"Error during analysis: {str(e)}"
|
|
@@ -344,14 +342,15 @@ with gr.Blocks(theme=gr.themes.Base()) as demo:
|
|
| 344 |
analyze_image_button = gr.Button("🔍 Analyze Image", variant="primary")
|
| 345 |
|
| 346 |
with gr.Row():
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
|
|
|
| 355 |
|
| 356 |
debug_output = gr.Textbox(
|
| 357 |
label="Debug Information",
|
|
|
|
| 148 |
analyzer = SAMAnalyzer(model_path=MODEL_PATH)
|
| 149 |
|
| 150 |
print("Processing image...")
|
| 151 |
+
veg_index, health_analysis, fig = analyzer.process_image(image)
|
| 152 |
|
| 153 |
if veg_index is None:
|
| 154 |
return None, "Error processing image.", "Image processing failed"
|
|
|
|
| 164 |
• High Vegetation: {health_analysis['health_distribution']['high_vegetation']*100:.1f}%
|
| 165 |
|
| 166 |
📋 Overall Health Status: {health_analysis['overall_health']}
|
|
|
|
|
|
|
| 167 |
"""
|
| 168 |
|
| 169 |
debug_msg = "Analysis completed successfully"
|
| 170 |
+
return fig, analysis_text, debug_msg
|
| 171 |
|
| 172 |
except Exception as e:
|
| 173 |
error_msg = f"Error during analysis: {str(e)}"
|
|
|
|
| 342 |
analyze_image_button = gr.Button("🔍 Analyze Image", variant="primary")
|
| 343 |
|
| 344 |
with gr.Row():
|
| 345 |
+
image_plot = gr.Plot(
|
| 346 |
+
label="Vegetation Analysis Results"
|
| 347 |
+
)
|
| 348 |
+
|
| 349 |
+
with gr.Row():
|
| 350 |
+
image_analysis = gr.Textbox(
|
| 351 |
+
label="Analysis Results",
|
| 352 |
+
lines=10
|
| 353 |
+
)
|
| 354 |
|
| 355 |
debug_output = gr.Textbox(
|
| 356 |
label="Debug Information",
|