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

If I wana detect small object, which args should I modify? #586

Closed
albertyou2 opened this issue May 22, 2017 · 19 comments
Closed

If I wana detect small object, which args should I modify? #586

albertyou2 opened this issue May 22, 2017 · 19 comments

Comments

@albertyou2
Copy link

@rbgirshick
Thanks for your good work!
I wana detect very small objects , like 10 * 10 .But I don't know how to do this .
I have search the hole issue list but didn't see any compelete instructions for this job.
Could you please show me a way to do this?something like which args to modified

Thank you

@djdam
Copy link

djdam commented May 22, 2017

I am struggling with this as well, though my objects can be in a range from +/- 5 to 100 px with different ratios. Most of my initial effort was targeted at changing the parameters going into the anchor_target_layer and proposal_layer:

  • scales: decrease these values to account for smaller boxes
  • ratios: adjust them depending on the shape of your grount-truth boxes
  • feat_stride : supposedly this can be modified to improve accuracy of the generated anchors

I made a script for analysing the images & boxes in your IMDB, it is available here:

https://github.com/djdam/faster-rcnn-scenarios/blob/master/src/analysis/imdb_analyse.py

@albertyou2
Copy link
Author

@djdam wow that's cool!
The script really helps!
I will try you suggestions soon ,Thank you very much!

@ravikantb
Copy link

@albertyou2 @djdam: Reducing the value of the following configuration while training may help you create a model that detects small objects. Using 4 instead of default 16 helped in my case.
https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/fast_rcnn/config.py#L118

You may also directly try changing the value at test time for your existing model at the following line. Not sure how good it would be though.
https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/fast_rcnn/config.py#L164

@albertyou2
Copy link
Author

hi @ravikantb
Thank you for your suggestion.And I 'am wondering if the RPN_MIN_SIZE is the only one parameter will effect the detection of small objects?

I have read some issues and articles , and I heard a parameter named something like 'min scale' or 'aspect ratio' .But it's very difficult for me to find they out.
sorry if this question is stupid ,as you see I 'm very new to caffe and DL.

@ravikantb
Copy link

@albertyou2 : My guess is the papers where you read about 'min scale' and 'aspect ratio' meant to refer to the anchor box ratios and scales. You will need to change them also (in addition to RPN_MIN_SIZE) to detect small objects. The default anchor boxes have 3 scales and 3 ratios (in total 9 anchor boxes for every position of feature map given by VGG/ZF convolution layers). Following method is called whenever reference to anchor boxes is needed:
https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/rpn/generate_anchors.py#L37

My suggestion would be to decrease the default ratios and scales. You can also add new ratios and scales in addition to default ones but then you will need to make some more changes in prototxts to account for change in RPN outputs triggered by change in anchor boxes. Let me know if you need any help in that.

@albertyou2
Copy link
Author

@ravikantb

Thank you .I will have a try as your helpful suggestion!
Have nice day!

@hito0512
Copy link

hito0512 commented Jun 2, 2017

@djdam i run the imdb_analyse.py,but it occue some errors: File "imdb_analyse.py", line 30, in get_statistics
for boxes, width, height, filename in [(entry['boxes'], entry['width'], entry['height'], entry['filename']) for entry in imdb.gt_roidb()]:
KeyError: 'width'
can u help me?

@djdam
Copy link

djdam commented Jun 2, 2017

@jiayandekafei

technicaldrawings_numbers_train is the name for my dataset. You need to change it to your own dataset's name.

about the width error, you need to modify your dataset factory Python file and add the missing keys to the roidb entries, like 'width', 'height' etc

@djdam
Copy link

djdam commented Jun 2, 2017

eg an example of a dataset factory is https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/datasets/pascal_voc.py . You probably have your own custom one. In the case of pascal_voc, you would need to add the height. width and filename keys in this line:

https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/datasets/pascal_voc.py#L220

@hito0512
Copy link

hito0512 commented Jun 2, 2017

@djdam i add as fllow:
return {'boxes' : boxes,
'width' : (x2 - x1 + 1),
'height': (y2 - y1 + 1),
'filename': filename,
is it right?

@djdam
Copy link

djdam commented Jun 2, 2017

looks good. Don't forget to delete the cached .pkl file

@hito0512
Copy link

hito0512 commented Jun 3, 2017

@djdam thank you ,have a nice day

@mysayalHan
Copy link

@djdam Did you try to remove layer 'pool4' in VGG16 in terms of small object? I got low score. Considering pooling is one kind of down-sampling, why the result was worse? Thanks

@liu09114
Copy link

good job

@315386775
Copy link

good job!

@xxc1005
Copy link

xxc1005 commented Dec 13, 2017

@ravikantb ,if I have changed the anchor ratio and scale,what should I do accompanied ?should I change the feat_stride?or something else?thanks

@ashnair1
Copy link

ashnair1 commented Apr 9, 2019

Hey @ravikantb and @djdam. I had a question regarding your modifications for detecting small objects. You said that changing ratios and decreasing scales would be a good idea. Isn't it possible to just reduce the base size of anchors while keeping all other parameters the same? For example, say the default anchors are (32,64,128,256,512), couldn't I just change it to (8,16,32,64,128) or (4,8,16,32,64) to detect smaller objects since the aspect ratios and scales are relative to the anchor size?

@zhilaAI
Copy link

zhilaAI commented Apr 23, 2019

Hey everybody, I have the same problem to detect very small object less than 10 pixels. Does this modification help me? I am using Faster rcnn by tensorflow

@HamdiTarek
Copy link

Hey @ravikantb and @djdam. I had a question regarding your modifications for detecting small objects. You said that changing ratios and decreasing scales would be a good idea. Isn't it possible to just reduce the base size of anchors while keeping all other parameters the same? For example, say the default anchors are (32,64,128,256,512), couldn't I just change it to (8,16,32,64,128) or (4,8,16,32,64) to detect smaller objects since the aspect ratios and scales are relative to the anchor size?

yes this works for me, even for objects small than 10 pixels, I used (4,8,16,32,64)

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