How to pass datapath of a dataset to python program


(Shivam Bhardwaj) #1

hello
i am running a program , in which i have to use a dataset of images, now i need to give datapath of dataset to python program. i have tried so many methods to do the same but i failed. i got following error
ipython-input-6-20f5453ca716> in ()
3 t_no = 0
4 for img_no in range(20):
----> 5 imD = Image.open(Datapath + str(img_no+21) + ‘_training.tif’)
6 imD = np.array(imD)
7

/home/user/anaconda2/lib/python2.7/site-packages/PIL/Image.pyc in open(fp, mode)
2475
2476 if filename:
-> 2477 fp = builtins.open(filename, “rb”)
2478 exclusive_fp = True
2479
IOError: [Errno 2] No such file or directory: ‘/home/user/Desktop/images21_training.tif’
Thank you


(Simon Wang) #2

hmm are you sure that your Datapath is set correctly?


(Shivam Bhardwaj) #3

Thanks to consider my problem
Actually I am new to Linux (Ubuntu 16.04) and pytorch . I have downloaded the data set in home/users/download. Now I need to pass datapath of dataset to program . What will be datapath of this dataset.


(Simon Wang) #4

According to your code it should be /home/users/download (or equivalent relevant path). This is more of a python question btw.


(Shivam Bhardwaj) #5

yes, i also think that but still my program is not error free.
plz, if possible help me.


#6

What kind of error message do you get?
Still that the file cannot be found?


(Shivam Bhardwaj) #7

meaning of error is my program is not able to open the images means program cannot access the dataset through the datapath provided to program


#8

Could you type ls your_path in your Terminal? It seems the file does not exist.