kikogazda commited on
Commit
0814784
·
verified ·
1 Parent(s): 1aa2b41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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", height=350),
64
  outputs=[
65
- gr.Image(type="pil", label="Grad-CAM++ Heatmap", height=350),
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++",