0

Hi I want to save the predicted image in a folder using the same name as the original but my cv2.imwrite is not saving the images in the folder.

path2=r'/data/folder/'
def get_segmented(image):
    for i, file in enumerate(glob.glob(image)):
        
        print(file,i)
        start_time = time()
        image = image_loader(file)
    
        output = model(image)
        output = output.detach().cpu()
        output = np.resize(output, (160, 160))
        
        img_filename = os.path.splitext(file)[0]
        print(cv2.imwrite(path2 + img_filename + '.png',output*255))
8
  • Why is there a print at the end? Have you tried avoiding print? I would try with just cv2.imwrite(path2 + img_filename + '.png',output*255). Commented Jul 10, 2021 at 3:49
  • Just to see the output is saving or not Commented Jul 10, 2021 at 3:56
  • What is your problem, saving file with original name or saving file? Commented Jul 10, 2021 at 3:57
  • saving with the original name. when I run this code cv2.imwrite output is False Commented Jul 10, 2021 at 4:00
  • What you you providing in image argument? and why are you implementing loop for there? and also are you sure that your output is of numpy.ndarray class? Commented Jul 10, 2021 at 4:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.