1

I have found a tutorial about how to train a neural net. How should I train a caffe module with my own dataset.

There is an axample Cats vs Dogs and it's clear for me, how I need to do with that data which consists of two types (Dogs and Cats). I have tried to follow his steps, and I got a result caffe module.

Then I would like to increase the type set, I mean, I have trained only on 2 types, now I want 19 types (yes, 19 - different objects) to train.

And the problem I have found is how should I increase the main selection in a caffe module?

Here is the part of the code where I found a problem:

dog_images = [image for image in os.listdir(DATA_DIR) if 'dog' in image]
cat_images = [image for image in os.listdir(DATA_DIR) if 'cat' in image]

dog_train = dog_images[:int(len(dog_images)*0.7)]
dog_test = dog_images[int(len(dog_images)*0.7):]

cat_train = cat_images[:int(len(cat_images)*0.7)]
cat_test = cat_images[int(len(cat_images)*0.7):]

I don't think that if I have 19 types, it means, I need 19 times to write the code like that (upper).

Also, I have my images not in different folders, I have one and there are about 4,000 images.

Shai
  • 111,146
  • 38
  • 238
  • 371
X21
  • 168
  • 2
  • 13

1 Answers1

2

You don't need to repeat that code 19 times. The only purpose of this code is to create 'train.txt' and 'test.txt' files that lists your image files and the label of each image.
I don't know how you organize the images on your disk (you say you have a single folder with 4K images) but you should be able to tell what label/class (0..18) each image belongs to. Once you have these lists in the file 'train.txt' and 'test.txt' you can proceed to cread train and validation datasets using convert_imageset tool.

Shai
  • 111,146
  • 38
  • 238
  • 371
  • Yes, thanks for replying. But as for my dataset, can you inform me , if I have my images in order, like: 0000.jpg , 0001.jpg .... 4000.jpg. ? How should I show my labels of my objects (0..18) – X21 Mar 21 '18 at 09:11
  • @X21 what is the label of `0001.jpg`? and `0002.jpg`? how do **you** know the labels? – Shai Mar 21 '18 at 09:41
  • That’s why I ask you. Because I don’t understand enough. Do I need to store pictures with labels , for example: scarf. jpg, dress.jpg and etc? So I need 19 folders with different objects. Am I right? – X21 Mar 21 '18 at 10:01
  • @X21 You only need a **list** that connects each image to its label. You should have two lists: one with **train** images and the other with **test** images. Each list has the format of `0001.jpg 3\n0002.jpg 15\n` etc. (assuming label of `0001.jpg` is 3 and `0002.jpg`'s 15...) – Shai Mar 21 '18 at 10:04
  • Thank you , I will try to do this. – X21 Mar 21 '18 at 10:06