ssd.pytorch icon indicating copy to clipboard operation
ssd.pytorch copied to clipboard

How to train own datasets?

Open zhanghan328 opened this issue 7 years ago • 26 comments

I have own datasets with labeled. How to train it?

zhanghan328 avatar May 02 '17 10:05 zhanghan328

That is high on the to-do list but haven't gotten around to making that easy yet. For now, I would recommend extending pytorch's dataset class so that it follows the functionality of our current VOC dataset class. Finishing up school next week and then I should be able to add that pretty quickly!

amdegroot avatar May 06 '17 00:05 amdegroot

I've actually tried to implement my own dataset according to the VOC dataloader. However at training time, I got NaN values at loss

andfoy avatar May 27 '17 22:05 andfoy

I'm also very interested in this. @andfoy @amdegroot @zhanghan328 have working code or places to start?

alexiskattan avatar Jun 28 '17 19:06 alexiskattan

@alexiskattan I wrote a Visual Genome dataset loader: https://github.com/andfoy/textobjdetection/blob/master/visual_genome_loader.py#L482

andfoy avatar Jun 28 '17 20:06 andfoy

here is our VOC Detection dataset: https://github.com/amdegroot/ssd.pytorch/blob/master/data/voc0712.py#L84

I would give it a look over, we have it extensively commented. I largely based the dataset off of the datasets found here in pytorch's torchvision dataset repo: https://github.com/pytorch/vision/tree/master/torchvision/datasets

Sorry for the late responses -- Max and I are both currently travelling post graduation, but should be able to pick back up our slack here in a couple of weeks!

ellisbrown avatar Jun 28 '17 20:06 ellisbrown

Thank you @ellisbrown and @andfoy. I'm looking at it now. I'm kinda new to this but will see how far I can get! <3

alexiskattan avatar Jun 28 '17 21:06 alexiskattan

Can confirm VGG gives NaN's with 2 class detection problem. Sometimes gives illegal memory access, which seems to be related to pytorch bug.

My MobileNet implementation achieved ~50% mAP on VOC2007 (160x160 input size). Can PR it here after sorting out issues with HollywoodHeads dataset.

Seems like with smaller objects priors are completely off and network doesn't train.

igrekun avatar Jun 28 '17 21:06 igrekun

@ellisbrown one thing that made training really easy for another library was to be able to input a text file that was like:

filepath,x1,y1,x2,y2,class_name filepath,x1,y1,x2,y2,class_name filepath,x1,y1,x2,y2,class_name

alexiskattan avatar Jun 28 '17 21:06 alexiskattan

@igrekun I'd be great to see how you did it. Would you mind pointing to link where it is?

alexiskattan avatar Jul 03 '17 02:07 alexiskattan

Until we get back from our summer vacations, I would recommend reading the issues people have posted on the original Caffè SSD repo regarding training custom datasets as I think I remember them being helpful.

amdegroot avatar Jul 04 '17 14:07 amdegroot

Just returned from my mountain trip and have to sort out work-related issues, so here is dirty and hacky gist to train mobilenet + SSD.

https://gist.github.com/igrekun/35129c5a1d4f7ef2ffecdf0560adfc1f

You can download pretrained on ImageNet MobileNet head here: https://s3.us-east-2.amazonaws.com/ig-models/mobilenet/mbnethead.pth

The trained model with 50.22 mAP on pascal is stored here: https://s3.us-east-2.amazonaws.com/ig-models/mobilenet/mbnet_iter_59800.pth

I'm busy for the next few days, but if you are interested, I will file a proper pull request. There is some redundancy with not using cfg values to initialize SSD prior boxes but we can sort that out.

Otherwise the codebase is clean and a pleasure to work with. Thanks, Max! (:

igrekun avatar Jul 09 '17 20:07 igrekun

@andfoy thanks for sharing your training implementation. What is the link for the article "Human-related Object Detection based on Natural Language Parsing of Image Query Expressions article"? is it this? http://ieeexplore.ieee.org/document/5363983/ cant seem to find it.

jtoy avatar Jul 15 '17 18:07 jtoy

@jtoy I'm actually on process of writing it, so is not published yet!

andfoy avatar Jul 15 '17 18:07 andfoy

@igrekun do you know what PyTorch bug this is? I've been getting strange errors while training to detect a single class of objects. But it occurs all the time from the start so could be an entirely different problem (or indeed some bug in my own code).

Can confirm VGG gives NaN's with 2 class detection problem. Sometimes gives illegal memory access, which seems to be related to pytorch bug.

romaniukm avatar Jul 24 '17 20:07 romaniukm

@igrekun I apologize for my tardy response. Feel free to submit a PR! I'm just getting back from a long summer break myself.

amdegroot avatar Jul 25 '17 00:07 amdegroot

Check out my solution here - https://github.com/amdegroot/ssd.pytorch/issues/72

aveysov avatar Oct 29 '17 09:10 aveysov

@zhanghan328 hi,could you please tell me how's your work going on,I have the same problem as yours. My wechat(微信):lijingx- thank you in advance!

li10141110 avatar Apr 18 '18 02:04 li10141110

any advance?

dongzhuoyao avatar May 29 '18 14:05 dongzhuoyao

Hey guys, interested to know if there was any progress on this??

shreyank13 avatar Oct 17 '18 15:10 shreyank13

any progress?

wagnzi avatar Oct 24 '18 07:10 wagnzi

I trained 12 categories dataset on this repo, firstly, I transformed my data to like coco format. And, I run the demo.py and can get normal results. however, when I want to use the coco api to eval my model for getting the mAP like coco dataset, I failed. But, I got all 0 result or nearly 0, which is likely the @banxia1994 and @Hliang1994 I got Running per image evaluation... Evaluate annotation type bbox DONE (t=0.36s). Accumulating evaluation results... DONE (t=0.10s). Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.000

The following code as my reference: I used the @lpd2csx code to record the ouput https://github.com/amdegroot/ssd.pytorch/issues/253

There are anyone eval the likely coco's format dataset' mAP results? looking forward to any reply.

Ai-is-light avatar Jun 02 '19 12:06 Ai-is-light

I trained 12 categories dataset on this repo, firstly, I transformed my data to like coco format. And, I run the demo.py and can get normal results. however, when I want to use the coco api to eval my model for getting the mAP like coco dataset, I failed. But, I got all 0 result or nearly 0, which is likely the @banxia1994 and @Hliang1994 I got Running per image evaluation... Evaluate annotation type bbox DONE (t=0.36s). Accumulating evaluation results... DONE (t=0.10s). Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.000

The following code as my reference: I used the @lpd2csx code to record the ouput #253

There are anyone eval the likely coco's format dataset' mAP results? looking forward to any reply.

Happy new year!Have you solved this problem?

lesonly avatar Jan 01 '20 11:01 lesonly

I've actually tried to implement my own dataset according to the VOC dataloader. However at training time, I got NaN values at loss

How may I train my custom coco dataset? @andfoy

Hemantr05 avatar Apr 21 '20 00:04 Hemantr05

@ellisbrown one thing that made training really easy for another library was to be able to input a text file that was like:

filepath,x1,y1,x2,y2,class_name filepath,x1,y1,x2,y2,class_name filepath,x1,y1,x2,y2,class_name

My thoughts are the same as yours.Do you realize the loading of this data format?

zzu0654 avatar Jul 12 '20 04:07 zzu0654

I trained 12 categories dataset on this repo, firstly, I transformed my data to like coco format. And, I run the demo.py and can get normal results. however, when I want to use the coco api to eval my model for getting the mAP like coco dataset, I failed. But, I got all 0 result or nearly 0, which is likely the @banxia1994 and @Hliang1994 I got Running per image evaluation... Evaluate annotation type bbox DONE (t=0.36s). Accumulating evaluation results... DONE (t=0.10s). Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.000 The following code as my reference: I used the @lpd2csx code to record the ouput #253 There are anyone eval the likely coco's format dataset' mAP results? looking forward to any reply.

Happy new year!Have you solved this problem?

hello,Have you solved this problem?

201814476 avatar Jul 27 '20 08:07 201814476

Have anyone come up with a method for choosing the values for the default boxes in config.py - see below

    'min_sizes': [30, 60, 111, 162, 213, 264],
    'max_sizes': [60, 111, 162, 213, 264, 315],
    'aspect_ratios': [[2], [2, 3], [2, 3], [2, 3], [2], [2]],

MaxwellHogan avatar Nov 30 '20 17:11 MaxwellHogan