Mojo
commited on
Commit
·
4669812
1
Parent(s):
8457417
Added files
Browse files
app.py
CHANGED
@@ -100,8 +100,8 @@ def generate_prediction(input_image, num_classes=3, show_gradcam=True, transpare
|
|
100 |
cam = GradCAM(model=model, target_layers=target_layers)
|
101 |
cam_generated = cam(input_tensor=input_image, targets=None)
|
102 |
cam_generated = cam_generated[0, :]
|
103 |
-
display_image = show_cam_on_image(
|
104 |
-
|
105 |
else:
|
106 |
display_image = orginal_img
|
107 |
|
@@ -121,8 +121,11 @@ def app_interface(
|
|
121 |
):
|
122 |
"""Function which provides the Gradio interface"""
|
123 |
input_image = resize_image_pil(input_image, 32, 32)
|
|
|
|
|
|
|
124 |
# Get the prediction for the input image along with confidence and display_image
|
125 |
-
confidences, display_image = generate_prediction(
|
126 |
|
127 |
if show_misclassified:
|
128 |
misclassified_fig, misclassified_axs = plot_misclassified_images(
|
|
|
100 |
cam = GradCAM(model=model, target_layers=target_layers)
|
101 |
cam_generated = cam(input_tensor=input_image, targets=None)
|
102 |
cam_generated = cam_generated[0, :]
|
103 |
+
display_image = show_cam_on_image(orginal_img / 255, cam_generated, use_rgb=True, image_weight=transparency)
|
104 |
+
|
105 |
else:
|
106 |
display_image = orginal_img
|
107 |
|
|
|
121 |
):
|
122 |
"""Function which provides the Gradio interface"""
|
123 |
input_image = resize_image_pil(input_image, 32, 32)
|
124 |
+
|
125 |
+
input_image = np.array(input_image)
|
126 |
+
org_img = input_image
|
127 |
# Get the prediction for the input image along with confidence and display_image
|
128 |
+
confidences, display_image = generate_prediction(org_img, num_classes, show_gradcam, transparency, layer_name)
|
129 |
|
130 |
if show_misclassified:
|
131 |
misclassified_fig, misclassified_axs = plot_misclassified_images(
|