amdegroot / ssd.pytorch

A PyTorch Implementation of Single Shot MultiBox Detector
MIT License
5.12k stars 1.74k forks source link

How to train own datasets? #16

Open zhanghan328 opened 7 years ago

zhanghan328 commented 7 years ago

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

amdegroot commented 7 years ago

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!

andfoy commented 7 years ago

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

alexiskattan commented 7 years ago

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

andfoy commented 7 years ago

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

ellisbrown commented 7 years ago

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!

alexiskattan commented 7 years ago

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

igrekun commented 7 years ago

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.

alexiskattan commented 7 years ago

@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 commented 7 years ago

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

amdegroot commented 7 years ago

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.

igrekun commented 7 years ago

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! (:

jtoy commented 7 years ago

@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.

andfoy commented 7 years ago

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

romaniukm commented 7 years ago

@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.

amdegroot commented 7 years ago

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

aveysov commented 6 years ago

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

li10141110 commented 6 years ago

@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!

dongzhuoyao commented 6 years ago

any advance?

shreyank13 commented 5 years ago

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

wagnzi commented 5 years ago

any progress?

Ai-is-light commented 5 years ago

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.

lesonly commented 4 years ago

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?

Hemantr05 commented 4 years ago

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

zzu0654 commented 4 years ago

@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?

201814476 commented 4 years ago

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?

MaxwellHogan commented 3 years ago

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]],