unet icon indicating copy to clipboard operation
unet copied to clipboard

[Errno 2] No such file or directory: '../npydata/imgs_train.npy'

Open alaeddine-abbagh opened this issue 6 years ago • 19 comments

[Errno 2] No such file or directory: '../npydata/imgs_train.npy' Does anyone have any idea?

alaeddine-abbagh avatar May 20 '18 21:05 alaeddine-abbagh

Hey, I encountered the same problem and I resolved it by providing the correct path details. So I started by making a separate results folder, within the unet folder.

I modified lines- 164, 169 and 173 in unet.py as follows: ` np.save('/Users/sukritipaul/unet/results/imgs_mask_test.npy', imgs_mask_test)

def save_img(self):
	print("array to image")
	imgs = np.load('/Users/sukritipaul/unet/results/imgs_mask_test.npy')
             # This should match the address in line 164
	for i in range(imgs.shape[0]):
		img = imgs[i]
		img = array_to_img(img)
		img.save("/Users/sukritipaul/unet/results/%d.jpg"%(i))

`

You will find the output images in the .../unet/results folder. Hope this helps! :)

JuOllie avatar May 23 '18 09:05 JuOllie

Thanks but I still struggle with the same error. It appears that there should be a file named "imgs_train.npy" that I don't have.

alaeddine-abbagh avatar May 23 '18 15:05 alaeddine-abbagh

Looks like you haven't implemented data.py before unet.py. Here's what I did, and it worked fine for me!

  1. I created a folder called npydata i.e. .../unet/data/npydata

  2. I edited the code in data.py and changed the data_path , label_path, test_path and npy_path to the correct path (corresponding to the directories in my system). You can try editing these in line 138, in data.py (I've included in below).

def __init__(self, out_rows, out_cols, data_path = "/Users/sukritipaul/unet/data/train/image", label_path = "/Users/sukritipaul/unet/data/train/label", test_path = "/Users/sukritipaul/unet/data/test", npy_path = "/Users/sukritipaul/unet/data/npydata", img_type = "tif"):

  1. Run data.py. Go to .../unet/data/npydata and check if you have these 3 files:
  • imgs_mask_train.npy
  • imgs_test.npy
  • imgs_train.npy

4.Edit and run unet.py and you're good to go :)

JuOllie avatar May 23 '18 16:05 JuOllie

".../data.py", line 162, in create_train_data midname=imgname[imgname.rindex("/")+1:]

Value error: substring not found

Hello, Plz help to resolve this error...

msng1 avatar May 24 '18 09:05 msng1

Just replace data.py 138

with this line :

def __init__(self, out_rows, out_cols, data_path = "./data/train/image", label_path = "./data/train/label", test_path = "./data/test", npy_path = "./data/npydata/", img_type = "tif"):

Then line 181 and 182

		np.save(self.npy_path + '/imgs_train.npy', imgdatas)
		np.save(self.npy_path + '/imgs_mask_train.npy', imglabels)

line 202 to

	np.save(self.npy_path + '/imgs_test.npy', imgdatas)

line 209, 211

		imgs_train = np.load('./data/npydata/imgs_train.npy')
		 
		imgs_mask_train = np.load('./data/npydata/imgs_mask_train.npy')

For testing purpose create a test_fileloading.py in same folder and run this code after you execute data.py

import glob

print(glob.glob('./data/train/image/*.tif'))

If you see a list with images name , You are set to go.

monk1337 avatar May 24 '18 19:05 monk1337

Thank you.. It worked for me.. but now I am facing this error... Plz help to remove this..

Error-- File "...\Anaconda3\lib\site-packages\PIL\Image.py", line 2548, in open fp = builtins.open(filename, "rb")

FileNotFoundError: [Errno 2] No such file or directory: '.../.spyder-py3/data/train/image/image\0.tif'

msng1 avatar May 25 '18 05:05 msng1

Have you replaced all the path same as I suggested?

monk1337 avatar May 25 '18 05:05 monk1337

Yes, I have replaced all the paths..

msng1 avatar May 25 '18 06:05 msng1

I have the same problem. @msng1 FileNotFoundError: [Errno 2] No such file or directory: './data/train/image/image\0.tif'

100lic avatar Jun 03 '18 11:06 100lic

Hey :) So I've written an article about how I went about training RGB images, using U-Net. Hope this clears a few queries!

https://medium.com/@sukritipaul005/learn-how-to-train-u-net-on-your-dataset-8e3f89fbd623

JuOllie avatar Jun 08 '18 23:06 JuOllie

hey i cant find line 164

SanaMunirKhan avatar Nov 13 '18 13:11 SanaMunirKhan

there is no unet.py file in the https://github.com/zhixuhao/unet . plz answer me

SanaMunirKhan avatar Nov 13 '18 13:11 SanaMunirKhan

hey i cant find line 164

The code has been changed. Look in the previous version of commits in data.py

matsujju avatar Dec 01 '18 19:12 matsujju

Thank you.. It worked for me.. but now I am facing this error... Plz help to remove this..

Error-- File "...\Anaconda3\lib\site-packages\PIL\Image.py", line 2548, in open fp = builtins.open(filename, "rb")

FileNotFoundError: [Errno 2] No such file or directory: '.../.spyder-py3/data/train/image/image\0.tif'

Have you solved this error?

matsujju avatar Dec 01 '18 19:12 matsujju

I have the same problem. @msng1 FileNotFoundError: [Errno 2] No such file or directory: './data/train/image/image\0.tif'

have you solved this error?

matsujju avatar Dec 01 '18 19:12 matsujju

Hey :) So I've written an article about how I went about training RGB images, using U-Net. Hope this clears a few queries!

https://medium.com/@sukritipaul005/learn-how-to-train-u-net-on-your-dataset-8e3f89fbd623

I am getting this error after running the code. ` midname = imgname[imgname.rindex("/")+1:]

ValueError: substring not found`

matsujju avatar Dec 02 '18 10:12 matsujju

Can anyone update the article? This repository has changed, and the old one seems to not work.

merveydn avatar May 05 '19 21:05 merveydn

Thank you.. It worked for me.. but now I am facing this error... Plz help to remove this..

Error-- File "...\Anaconda3\lib\site-packages\PIL\Image.py", line 2548, in open fp = builtins.open(filename, "rb")

FileNotFoundError: [Errno 2] No such file or directory: '.../.spyder-py3/data/train/image/image\0.tif'

I solved it by making another image folder inside the image folder and paste all the image in it

emonome avatar Feb 18 '21 07:02 emonome

Can anyone update the article? This repository has changed, and the old one seems to not work.

Please use the server 2 repository.

emonome avatar Feb 18 '21 07:02 emonome