Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,8 +75,8 @@ def iou_score(pred_mask, gt_mask):
|
|
| 75 |
|
| 76 |
def predict_and_compare(mri_image, ground_truth_mask):
|
| 77 |
"""Predicts a tumor mask and compares it to a ground truth mask."""
|
| 78 |
-
mri_image_np = np.array(mri_image_np.convert('RGB')) if
|
| 79 |
-
ground_truth_mask_np = np.array(ground_truth_mask_np.convert('L')) if
|
| 80 |
if BEST_MODEL is None:
|
| 81 |
return None, None, "Error: Model not loaded. Please check model path."
|
| 82 |
if mri_image_np is None:
|
|
@@ -133,7 +133,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="🧠👁️ BrainVision") as demo:
|
|
| 133 |
|
| 134 |
with gr.Accordion("📖 How to Use", open=True):
|
| 135 |
gr.Markdown("""
|
| 136 |
-
1. **Upload MRI Image**: Upload a brain MRI scan
|
| 137 |
2. **Upload Ground Truth** (optional): For performance evaluation
|
| 138 |
3. **Click Predict**: Run the segmentation model
|
| 139 |
4. **View Results**: See the predicted tumor mask overlaid on the original image
|
|
|
|
| 75 |
|
| 76 |
def predict_and_compare(mri_image, ground_truth_mask):
|
| 77 |
"""Predicts a tumor mask and compares it to a ground truth mask."""
|
| 78 |
+
mri_image_np = np.array(mri_image_np.convert('RGB')) if mri_image else None
|
| 79 |
+
ground_truth_mask_np = np.array(ground_truth_mask_np.convert('L')) if ground_truth_mask else None
|
| 80 |
if BEST_MODEL is None:
|
| 81 |
return None, None, "Error: Model not loaded. Please check model path."
|
| 82 |
if mri_image_np is None:
|
|
|
|
| 133 |
|
| 134 |
with gr.Accordion("📖 How to Use", open=True):
|
| 135 |
gr.Markdown("""
|
| 136 |
+
1. **Upload MRI Image** (required): Upload a brain MRI scan
|
| 137 |
2. **Upload Ground Truth** (optional): For performance evaluation
|
| 138 |
3. **Click Predict**: Run the segmentation model
|
| 139 |
4. **View Results**: See the predicted tumor mask overlaid on the original image
|