Spaces:
Sleeping
Sleeping
Commit
·
20700c3
1
Parent(s):
383e8f6
Debug: refactor src
Browse files
yolov8.py
CHANGED
@@ -55,13 +55,12 @@ def xai_yolov8s(image):
|
|
55 |
model.eval()
|
56 |
results = model(image)
|
57 |
detections = results[0]
|
58 |
-
|
59 |
boxes, colors, names = parse_detections(detections, model)
|
60 |
detections_img = draw_detections(boxes, colors, names, image.copy())
|
61 |
img_float = np.float32(image) / 255
|
62 |
transform = transforms.ToTensor()
|
63 |
tensor = transform(img_float).unsqueeze(0)
|
64 |
-
target_layers = [model.model[-2]] # Adjust
|
65 |
cam_image, renormalized_cam_image = generate_cam_image(model.model, target_layers, tensor, image, boxes)
|
66 |
final_image = np.hstack((image, cam_image, renormalized_cam_image))
|
67 |
caption = "Results using YOLOv8"
|
|
|
55 |
model.eval()
|
56 |
results = model(image)
|
57 |
detections = results[0]
|
|
|
58 |
boxes, colors, names = parse_detections(detections, model)
|
59 |
detections_img = draw_detections(boxes, colors, names, image.copy())
|
60 |
img_float = np.float32(image) / 255
|
61 |
transform = transforms.ToTensor()
|
62 |
tensor = transform(img_float).unsqueeze(0)
|
63 |
+
target_layers = [model.model.model[-2]] # Adjust to YOLOv8 architecture
|
64 |
cam_image, renormalized_cam_image = generate_cam_image(model.model, target_layers, tensor, image, boxes)
|
65 |
final_image = np.hstack((image, cam_image, renormalized_cam_image))
|
66 |
caption = "Results using YOLOv8"
|