Spaces:
Sleeping
Sleeping
blend sample image and viz
Browse files
yolov5.py
CHANGED
@@ -234,10 +234,15 @@ def dff_nmf(image, target_lyr, n_components):
|
|
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 |
|
238 |
#temp = image_array.reshape((rgb_img_float.shape[0],rgb_img_float.shape[1]) )
|
239 |
-
visualization = show_factorization_on_image(rgb_img_float, image_array.resize((rgb_img_float.shape)) , image_weight=0.3)
|
240 |
-
results.append(
|
241 |
plt.clf()
|
242 |
#return image_array
|
243 |
|
|
|
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] / 255.0
|
240 |
+
rgb_channels = np.stack(rgba_channels[:3], axis=-1)
|
241 |
+
overlay_img = (alpha_channel[..., None] * image) + ((1 - alpha_channel[..., None]) * rgb_channels)
|
242 |
|
243 |
#temp = image_array.reshape((rgb_img_float.shape[0],rgb_img_float.shape[1]) )
|
244 |
+
#visualization = show_factorization_on_image(rgb_img_float, image_array.resize((rgb_img_float.shape)) , image_weight=0.3)
|
245 |
+
results.append(overlay_img)
|
246 |
plt.clf()
|
247 |
#return image_array
|
248 |
|