BhumikaMak commited on
Commit
359b749
·
verified ·
1 Parent(s): 9654321

update: direct array return

Browse files
Files changed (1) hide show
  1. yolov5.py +9 -4
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
- plt.show()
232
- plt.savefig("test_" + str(indx) + ".png" )
233
- plt.clf()
234
- results.append(Image.open(f"test_{indx}.png"))
 
 
 
 
 
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