Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,15 +54,15 @@ def predict_and_explain(img):
|
|
| 54 |
image_np = np.array(image_pil).astype(np.float32) / 255.0
|
| 55 |
cam_image = show_cam_on_image(image_np, grayscale_cam, use_rgb=True)
|
| 56 |
|
| 57 |
-
cam_pil = Image.fromarray(cam_image)
|
| 58 |
return cam_pil, f"Prediction: {pred_name} (class index {pred_idx})"
|
| 59 |
|
| 60 |
# --- Gradio UI ---
|
| 61 |
demo = gr.Interface(
|
| 62 |
fn=predict_and_explain,
|
| 63 |
-
inputs=gr.Image(type="pil", label="Upload Car Image"
|
| 64 |
outputs=[
|
| 65 |
-
gr.Image(type="pil", label="Grad-CAM++ Heatmap"
|
| 66 |
gr.Text(label="Prediction")
|
| 67 |
],
|
| 68 |
title="🚗 EfficientNetV2 Car Classifier + Grad-CAM++",
|
|
|
|
| 54 |
image_np = np.array(image_pil).astype(np.float32) / 255.0
|
| 55 |
cam_image = show_cam_on_image(image_np, grayscale_cam, use_rgb=True)
|
| 56 |
|
| 57 |
+
cam_pil = Image.fromarray(cam_image).resize(img.size) # Resize to match original
|
| 58 |
return cam_pil, f"Prediction: {pred_name} (class index {pred_idx})"
|
| 59 |
|
| 60 |
# --- Gradio UI ---
|
| 61 |
demo = gr.Interface(
|
| 62 |
fn=predict_and_explain,
|
| 63 |
+
inputs=gr.Image(type="pil", label="Upload Car Image"),
|
| 64 |
outputs=[
|
| 65 |
+
gr.Image(type="pil", label="Grad-CAM++ Heatmap"),
|
| 66 |
gr.Text(label="Prediction")
|
| 67 |
],
|
| 68 |
title="🚗 EfficientNetV2 Car Classifier + Grad-CAM++",
|