Spaces:
Sleeping
Sleeping
Commit
·
1ac603d
1
Parent(s):
dced210
Removed GradCAM
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ data = "data.yaml"
|
|
| 22 |
# Load model
|
| 23 |
device = select_device('cpu')
|
| 24 |
model = DetectMultiBackend(weights, device=device, dnn=False, data=data, fp16=False)
|
| 25 |
-
target_layers = [model.model.model[-1]]
|
| 26 |
|
| 27 |
false_detection_data = glob(os.path.join("false_detection", '*.jpg'))
|
| 28 |
false_detection_data = [x.replace('\\', '/') for x in false_detection_data]
|
|
@@ -113,11 +113,11 @@ def inference(input_img, conf_thres, iou_thres, is_false_detection_images=True,
|
|
| 113 |
else:
|
| 114 |
misclassified_images = None
|
| 115 |
|
| 116 |
-
cam = EigenCAM(model, target_layers)
|
| 117 |
-
grayscale_cam = cam(im)[0, :]
|
| 118 |
-
cam_image = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)
|
| 119 |
|
| 120 |
-
return im0,
|
| 121 |
|
| 122 |
title = "YOLOv9 model to detect shirt/tshirt"
|
| 123 |
description = "A simple Gradio interface to infer on YOLOv9 model and detect tshirt in image"
|
|
@@ -138,8 +138,7 @@ demo = gr.Interface(inference,
|
|
| 138 |
gr.Slider(0, 1, 0.45, label="IoU Thresold"),
|
| 139 |
gr.Checkbox(label="Show False Detection"),
|
| 140 |
gr.Slider(5, 35, value=10, step=5, label="Number of False Detection")],
|
| 141 |
-
outputs= [gr.Image(width=640, height=640, label="Output"),
|
| 142 |
-
gr.Plot(label="GradCAM"),
|
| 143 |
gr.Plot(label="False Detection")],
|
| 144 |
title=title,
|
| 145 |
description=description,
|
|
|
|
| 22 |
# Load model
|
| 23 |
device = select_device('cpu')
|
| 24 |
model = DetectMultiBackend(weights, device=device, dnn=False, data=data, fp16=False)
|
| 25 |
+
#target_layers = [model.model.model[-1]]
|
| 26 |
|
| 27 |
false_detection_data = glob(os.path.join("false_detection", '*.jpg'))
|
| 28 |
false_detection_data = [x.replace('\\', '/') for x in false_detection_data]
|
|
|
|
| 113 |
else:
|
| 114 |
misclassified_images = None
|
| 115 |
|
| 116 |
+
# cam = EigenCAM(model, target_layers)
|
| 117 |
+
# grayscale_cam = cam(im)[0, :]
|
| 118 |
+
# cam_image = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)
|
| 119 |
|
| 120 |
+
return im0, misclassified_images
|
| 121 |
|
| 122 |
title = "YOLOv9 model to detect shirt/tshirt"
|
| 123 |
description = "A simple Gradio interface to infer on YOLOv9 model and detect tshirt in image"
|
|
|
|
| 138 |
gr.Slider(0, 1, 0.45, label="IoU Thresold"),
|
| 139 |
gr.Checkbox(label="Show False Detection"),
|
| 140 |
gr.Slider(5, 35, value=10, step=5, label="Number of False Detection")],
|
| 141 |
+
outputs= [gr.Image(width=640, height=640, label="Output"),
|
|
|
|
| 142 |
gr.Plot(label="False Detection")],
|
| 143 |
title=title,
|
| 144 |
description=description,
|