Spaces:
Sleeping
Sleeping
Commit
·
cf9410f
1
Parent(s):
9d9357e
Updated GradCAM
Browse files
app.py
CHANGED
@@ -68,12 +68,7 @@ def inference(input_img, conf_thres, iou_thres, is_false_detection_images=True,
|
|
68 |
im0 = input_img.copy()
|
69 |
im_resized = cv2.resize(im0, (640, 640))
|
70 |
rgb_img = im_resized.copy()
|
71 |
-
transforms = albumentations.Compose(
|
72 |
-
# Normalize
|
73 |
-
[albumentations.Normalize([0.49139968, 0.48215841, 0.44653091],
|
74 |
-
[0.24703223, 0.24348513, 0.26158784]),
|
75 |
-
# Convert to tensor
|
76 |
-
ToTensorV2()])
|
77 |
im_resized = transforms(image = im_resized)['image']
|
78 |
im_resized = im_resized.unsqueeze(0)
|
79 |
stride, names, pt = model.stride, model.names, model.pt
|
@@ -123,9 +118,9 @@ def inference(input_img, conf_thres, iou_thres, is_false_detection_images=True,
|
|
123 |
misclassified_images = None
|
124 |
|
125 |
cam = EigenCAM(model, target_layers)
|
126 |
-
grayscale_cam = cam(im_resized)[0,
|
127 |
cam_image = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)
|
128 |
-
|
129 |
return im0, cam_image, misclassified_images
|
130 |
|
131 |
title = "YOLOv9 model to detect shirt/tshirt"
|
|
|
68 |
im0 = input_img.copy()
|
69 |
im_resized = cv2.resize(im0, (640, 640))
|
70 |
rgb_img = im_resized.copy()
|
71 |
+
transforms = albumentations.Compose([ToTensorV2()])
|
|
|
|
|
|
|
|
|
|
|
72 |
im_resized = transforms(image = im_resized)['image']
|
73 |
im_resized = im_resized.unsqueeze(0)
|
74 |
stride, names, pt = model.stride, model.names, model.pt
|
|
|
118 |
misclassified_images = None
|
119 |
|
120 |
cam = EigenCAM(model, target_layers)
|
121 |
+
grayscale_cam = cam(im_resized)[0, :]
|
122 |
cam_image = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)
|
123 |
+
|
124 |
return im0, cam_image, misclassified_images
|
125 |
|
126 |
title = "YOLOv9 model to detect shirt/tshirt"
|