enter image description herei have 3000 images for both training and testing in one folder and i also have the image label in label.csv file which has the five class categories. Can anyone help me how to split this dataset into train and test data so that i can classify the images using convolution neural network. My dataset looks like the following image after the linking with csv and images.
Asked
Active
Viewed 1,494 times
0
-
4What have you tried so far? Please provide [Minimal, Complete, and Verifiable Code](https://stackoverflow.com/help/mcve). – Partho63 Feb 19 '19 at 04:57
-
1Since you added the tag tensorflow I think you can check this question: https://stackoverflow.com/questions/51125266/how-do-i-split-tensorflow-datasets and if it's more on the conceptual side, meaning proper amounts for splitting, it depends a lot on the use case, which is better explained here: https://stackoverflow.com/questions/13610074/is-there-a-rule-of-thumb-for-how-to-divide-a-dataset-into-training-and-validatio – bpinaya Feb 19 '19 at 13:02
-
put your csv file here and I will tell you. – leo Feb 19 '19 at 18:59
1 Answers
0
First, you need an association between images and labels (some kind of knowledge of which label belongs to which image). Otherwise it will not work properly. After that you can split your dataset. Here is a toy example, assuming full_dataset
contains the whole dataset and SIZE_OF_DATASET
is the size of full_dataset
:
full_dataset = full_dataset.shuffle()
train_dataset = full_dataset.take(int(0.8*SIZE_OF_DATASET))
test_dataset = full_dataset.skip(int(0.2*SIZE_OF_DATASET))

Simdi
- 794
- 4
- 13
-
Thank you Simdi sir. I have a data frame df which contain the above image in which level_cat denotes the labels of the images. can you please guide me the further process? I have done with manually splitting and make the different folder but its lengthy process. Thank you once again. – Ramchandra Regmi Feb 26 '19 at 09:19
-
The image contained in your question contains the needed association from image (image column) and labels (cat_level column). If you know create a batch, you just have to collect the labels (which you get through this association) in the right order – Simdi Feb 26 '19 at 09:40