Spaces:
Sleeping
Sleeping
update: xai_yolov5 added support for dff
Browse files
yolov5.py
CHANGED
@@ -76,8 +76,12 @@ def xai_yolov5(image):
|
|
76 |
# Grad-CAM visualization
|
77 |
cam_image, renormalized_cam_image = generate_cam_image(model, target_layers, tensor, image, boxes)
|
78 |
|
|
|
|
|
|
|
|
|
79 |
# Combine results
|
80 |
-
final_image = np.hstack((image, detections_img, renormalized_cam_image))
|
81 |
caption = "Results using YOLOv5"
|
82 |
return Image.fromarray(final_image), caption
|
83 |
|
@@ -244,4 +248,3 @@ def visualize_batch_explanations(rgb_img_float, batch_explanations, image_weight
|
|
244 |
plt.axis('off') # Hide axes
|
245 |
plt.show() # Show the plot
|
246 |
plt.savefig("test_w.png")
|
247 |
-
|
|
|
76 |
# Grad-CAM visualization
|
77 |
cam_image, renormalized_cam_image = generate_cam_image(model, target_layers, tensor, image, boxes)
|
78 |
|
79 |
+
rgb_img_float, batch_explanations = dff_nmf(image, target_lyr = -5, n_components = 8)
|
80 |
+
visualize_batch_explanations(rgb_img_float, batch_explanations)
|
81 |
+
im = cv2.imread("test_w.png")
|
82 |
+
|
83 |
# Combine results
|
84 |
+
final_image = np.hstack((image, detections_img, renormalized_cam_image, im))
|
85 |
caption = "Results using YOLOv5"
|
86 |
return Image.fromarray(final_image), caption
|
87 |
|
|
|
248 |
plt.axis('off') # Hide axes
|
249 |
plt.show() # Show the plot
|
250 |
plt.savefig("test_w.png")
|
|