Spaces:
Sleeping
Sleeping
update: direct array return
Browse files
yolov5.py
CHANGED
@@ -228,10 +228,15 @@ def dff_nmf(image, target_lyr, n_components):
|
|
228 |
predicted_label = labels[top_class_id] # Map ID to label
|
229 |
ax.text(x1, y1, f"{predicted_label}: {top_score:.2f}",
|
230 |
color='r', fontsize=12, verticalalignment='top')
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
return rgb_img_float, batch_explanations, results
|
237 |
|
|
|
228 |
predicted_label = labels[top_class_id] # Map ID to label
|
229 |
ax.text(x1, y1, f"{predicted_label}: {top_score:.2f}",
|
230 |
color='r', fontsize=12, verticalalignment='top')
|
231 |
+
|
232 |
+
|
233 |
+
fig.canvas.draw() # Draw the canvas to make sure the image is rendered
|
234 |
+
image_array = np.array(fig.canvas.renderer.buffer_rgba()) # Convert to numpy array
|
235 |
+
results.append(image_array)
|
236 |
+
plt.clf()
|
237 |
+
|
238 |
+
return image_array
|
239 |
+
|
240 |
|
241 |
return rgb_img_float, batch_explanations, results
|
242 |
|