Spaces:
Sleeping
Sleeping
debug: list index out of range
Browse files
yolov5.py
CHANGED
@@ -90,6 +90,7 @@ def xai_yolov5(image,target_lyr = -5, n_components = 8):
|
|
90 |
|
91 |
rgb_img_float, batch_explanations, result = dff_nmf(image, target_lyr = -5, n_components = 8)
|
92 |
#result = np.hstack(result)
|
|
|
93 |
im = visualize_batch_explanations(rgb_img_float, batch_explanations) ##########to be displayed
|
94 |
|
95 |
# Combine results
|
@@ -233,14 +234,13 @@ def dff_nmf(image, target_lyr, n_components):
|
|
233 |
|
234 |
fig.canvas.draw() # Draw the canvas to make sure the image is rendered
|
235 |
image_array = np.array(fig.canvas.renderer.buffer_rgba()) # Convert to numpy array
|
236 |
-
print("____________image_arrya", image_array.shape)
|
237 |
image_resized = cv2.resize(image_array, (640, 640))
|
238 |
rgba_channels = cv2.split(image_resized)
|
239 |
alpha_channel = rgba_channels[3]
|
240 |
rgb_channels = np.stack(rgba_channels[:3], axis=-1)
|
241 |
-
|
242 |
print("shape....", rgb_img_float.shape, rgb_channels.shape)
|
243 |
-
visualization = show_factorization_on_image(rgb_img_float, rgb_channels , image_weight=0.3)
|
244 |
|
245 |
#temp = image_array.reshape((rgb_img_float.shape[0],rgb_img_float.shape[1]) )
|
246 |
#visualization = show_factorization_on_image(rgb_img_float, image_array.resize((rgb_img_float.shape)) , image_weight=0.3)
|
|
|
90 |
|
91 |
rgb_img_float, batch_explanations, result = dff_nmf(image, target_lyr = -5, n_components = 8)
|
92 |
#result = np.hstack(result)
|
93 |
+
print("sample...",rgb_img_float.shape,batch_explanations.shape )
|
94 |
im = visualize_batch_explanations(rgb_img_float, batch_explanations) ##########to be displayed
|
95 |
|
96 |
# Combine results
|
|
|
234 |
|
235 |
fig.canvas.draw() # Draw the canvas to make sure the image is rendered
|
236 |
image_array = np.array(fig.canvas.renderer.buffer_rgba()) # Convert to numpy array
|
|
|
237 |
image_resized = cv2.resize(image_array, (640, 640))
|
238 |
rgba_channels = cv2.split(image_resized)
|
239 |
alpha_channel = rgba_channels[3]
|
240 |
rgb_channels = np.stack(rgba_channels[:3], axis=-1)
|
241 |
+
overlay_img = (alpha_channel[..., None] * image) + ((1 - alpha_channel[..., None]) * rgb_channels)
|
242 |
print("shape....", rgb_img_float.shape, rgb_channels.shape)
|
243 |
+
#visualization = show_factorization_on_image(rgb_img_float, rgb_channels , image_weight=0.3)
|
244 |
|
245 |
#temp = image_array.reshape((rgb_img_float.shape[0],rgb_img_float.shape[1]) )
|
246 |
#visualization = show_factorization_on_image(rgb_img_float, image_array.resize((rgb_img_float.shape)) , image_weight=0.3)
|