I have an array of output images which I am displaying runtime one after the other. I want to save the images inside a folder named 'saved images'. The current code I made saves the images, the images are not saved separately as soon as image1 is generated and saved in image1.png image2 overwrites its location how do I avoid overwriting the previous image with new image
for image_path in TEST_IMAGE_PATHS:
image = Image.open(image_path)
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = load_image_into_numpy_array(image)
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)
plt.savefig('image1.png')
plt.figure(figsize=IMAGE_SIZE)
plt.imshow(image_np)
vis_util.visualize_boxes_and_labels_on_image_array, it's possible that you are saving the wrong figureplt.savefig("your_folder/your_file.png").