How to use ImageClassifierData.from_csv if test.csv is also given

when i was reading the doc for ImageClassifierData.from_csv .it is said This method should be used when training image labels are given in an CSV file as opposed to sub-directories with label names.

then what if in any of the problem statement test.csv is also given ,then which method to use so that we can make prediction on the images_name of the test.csv file with test folder consisting of all images of the target variable .

please i humbly request experienced practitioners to have a glance over my query i really need help in solving this query which is running in my mind for past 2 days.

thanks in advance

1 Like

You’ll need to use python to read the csv and place those files into a separate folder.

1 Like

alright if i do put train.csv and train(folder which consist of images,mentioned in train.csv ) under folder A
and test.csv and test(folder which consist of images,mentioned in test.csv ) under folder B.

how it will make any difference ,because still how i will be able to use test.csv in order to make prediction .

in order to explain you better regarding my query let me give you an example ,
it is somewhat related to machine learning problem in which we are given two csv file one is test.csv and another one is train.csv with a target variable and then we have to determine the target variable for test.csv file

in the same way,what if a problem statement is given in which it consist of train.csv file with id and target variable and a folder named train is also given which consist of images mentioned under a column named image_name
and then a test.csv file is also given in which we have to determine the target variable with respect to different id’s,a folder named test is also given which consist of images mentioned under a column named image_name .
i hope this time i was able to explain my problem to all advanced practitioners in a better way

spear me please, for such a long explanation

as always,i’ll be humbly thankful for your responses

The from Csv method is to be used when all you have is a single folder with all images belonging to different classes which needs to be trained for the training test. In this case you normally will have an excel file that details the images names and the class the image names belong to. If you don’t have one given, then you will have to make one. You will also mention this excel file name in the ImageClassifierData.from_csv() method like

ImageClassifierData.from_csv(PATH, ‘train-jpg’, label_csv, tfms=tfms, suffix=’.jpg’, val_idxs=val_idxs, test_name=‘test-jpg’)

You can refer to Lesson No 2 of the course lesson2-image_models.ipynb. Now normally you will be given a test folder with all images without their classes. If you are not given one such folder but given an excel file with their names, then use python to read the file and move only those images from whichever folder they are in to another folder and you name that as ‘test’. Hope this clarifies.

4 Likes