Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training custom dataset on kangaroo #203

Open
voqtuyen opened this issue Mar 23, 2018 · 11 comments
Open

Training custom dataset on kangaroo #203

voqtuyen opened this issue Mar 23, 2018 · 11 comments

Comments

@voqtuyen
Copy link

I followed the tutorial on how to train custom dataset and i chose kangaroo.
Here is the log:

31/50 [=================>............] - ETA: 3:33 - loss: 1.4822Dummy Line 	[0]
Loss XY 	[0.0825796127]
Loss WH 	[1.9374851]
Loss Conf 	[0.0127458191]
Loss Class 	[0]
Total Loss 	[2.03281069]
Current Recall 	[0]
Average Recall 	[0.164205089]
32/50 [==================>...........] - ETA: 3:21 - loss: 1.4994Dummy Line 	[0]
Loss XY 	[0.106220111]
Loss WH 	[1.57395577]
Loss Conf 	[0.00985390227]
Loss Class 	[0]
Total Loss 	[1.69002986]
Current Recall 	[0]
Average Recall 	[0.163336292]
33/50 [==================>...........] - ETA: 3:11 - loss: 1.5051Dummy Line 	[0]
Loss XY 	[0.0952992663]
Loss WH 	[1.51814735]
Loss Conf 	[0.00849177]
Loss Class 	[0]
Total Loss 	[1.62193835]
Current Recall 	[0]
Average Recall 	[0.162476614]
34/50 [===================>..........] - ETA: 2:59 - loss: 1.5086Dummy Line 	[0]
Loss XY 	[0.093166858]
Loss WH 	[1.39261317]
Loss Conf 	[0.0124569423]
Loss Class 	[0]
Total Loss 	[1.49823689]
Current Recall 	[0]
Average Recall 	[0.161625952]

The loss class is always 0, and the final model cannot predict the kangaroo correctly. Any suggestions on how to resolve it? Thanks so much!

@experiencor
Copy link
Owner

@voqtuyen Class loss is always 0 as you only have 1 class. You cannot get it wrong.

For correct prediction, please use Full Yolo and train more to reduce the loss further.

@voqtuyen
Copy link
Author

Thanks @experiencor for your reply, i will try a re-training as your suggestion

@voqtuyen
Copy link
Author

voqtuyen commented Mar 26, 2018

Hi @experiencor ,

I see that during training the recall decreases overtime? I think it's quite strange and it results in my wrong prediction result, is it supposed to be normal?
I have applied warm-up training with 3 epochs and use that for actual training process for the kangaroo dataset given by your github. The recall is quite slow at about 0.09. I'm thinking of training about 2-3 examples to make it over-fitted to validate the training process.
Also, how many epochs do you expect to run on kangaroo dataset?
Thanks for your time

@experiencor
Copy link
Owner

Hi @voqtuyen, I find that the warmup stage is quite confusing so I changed the code to auto handle this case. The training process is now simply python train.py -c config.json. May you try it again.

@voqtuyen
Copy link
Author

Hi @experiencor,

Thanks for your quick reply, i will give it a try then!
Have a nice day!

@voqtuyen
Copy link
Author

voqtuyen commented Mar 27, 2018

Hi @experiencor,
I have another problem here, i have trained kangaroo dataset with the final average recall about 0.4. The model is able to predict the kangaroo on images but with default 0.3 confidence, it thinks a person is a kangaroo in some cases. However, my real problem is that when i test the model on cat.jpg or dog.jpg... it also thinks a cat is a kangaroo (with very high confidence???). For now, i don't know why causes this to mis-classify these cases.
Also i see that my weight is very big about 600Mb compared to yours. What do you think?
Thanks for your help!
eagle_detected

@experiencor
Copy link
Owner

experiencor commented Mar 27, 2018

@voqtuyen Yes, your result is normal to me. One way to address this issue to include non-kangaroo images in the dataset. You can get some from COCO too. The network will learn to recognize non-kangaroo and not just label every animal as a kangaroo.

The size of the file is normal and Keras try to save 64-bit double. You may find out how to save in 32-bit.

@voqtuyen
Copy link
Author

Hi @experiencor ,
Thanks for your useful info. The way to do this is to just put more non-kangaroo dataset like COCO to the images & annotations dir and re-run the training process. The preprocessing step will handle objects that don't belong to the predefined labels and leave all the x_batch, y_batch to zeros to denote the absence of kangaroo. Is that correct?

@experiencor
Copy link
Owner

experiencor commented Mar 28, 2018

@voqtuyen Yes. You need to combine the images and the annotations (put them in common folders). Then set labels in config.json to like ["kangaroo", "dog", "cat"]. It will learn a detector which can distinguish those three animals.

If you just want to detect kangaroo, you can make blank annotations for those additional images then put ["kangaroo"] in the labels settings.

@voqtuyen
Copy link
Author

voqtuyen commented Mar 29, 2018

Thanks @experiencor,

I see that you divide the network into 2 parts: backend and frontend so that you can easily change the CNN architecture and also easily change the config of the last prediction layer, so my question is given a full model, how can i extract only the backend or frontend as you did (full_yolo_backend.h5)? Thanks very much!

@experiencor
Copy link
Owner

experiencor commented Mar 30, 2018

@voqtuyen It's straight-forward but involves quite an effort. Make the backend submodel, make the frontend submodel, combine them to make the full model, load the weight to the full model, save each submodel separately. I did all these steps in the constructor of YOLO in frontend.py except for the last two steps. You probably need a jupyter notebook to make your life easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants