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

Train on images without boxes #69

Open
andraugust opened this issue Aug 21, 2019 · 6 comments
Open

Train on images without boxes #69

andraugust opened this issue Aug 21, 2019 · 6 comments

Comments

@andraugust
Copy link

Thanks for the great package!

Is it possible to train on images that don't have boxes in them?

I have several images without boxes that serve as background examples. I'd like the model to learn from these. I believe the dataloader is set up to only load images with boxes, is this true?

@qfgaohao
Copy link
Owner

Hi @andraugust , therectically, yes. The background images will only provide negative samples. You just need to make sure there is at least one image with bounding boxes (positie samples) in every batch during training.

@lyyiangang
Copy link

I succeed make the training support background images. you need modify hard_negative_mining to support it.

@Barath19
Copy link

How can we reduce the number of default boxes per feature map?
can it be done by having single aspect ratio and size per map?

@ZHuiLBo
Copy link

ZHuiLBo commented Mar 19, 2020

I succeed make the training support background images. you need modify hard_negative_mining to support it.

Could you be more specific?

@ChetanPatil28
Copy link

ChetanPatil28 commented Apr 17, 2020

@Barath19 we can do that.
For that, u need to make changes in three files.

Following changes are with-respect-to SSD-Mobilenet-V2-Lite

1. ~\pytorchssd\vision\ssd\config\mobilenetv1_ssd_config.py
If you see inside this file,
there is a variable specs and it consists of four parameters,
there is a last parameter which is basically a List, and this parameter is aspect ratio.
Make this list with a single item of your desired aspect ratio.
For example, u want an asapect ratio of 0.49, do it this way,
SSDSpec(10, 32, SSDBoxSizes(105, 150), [ 0.490]).
Similarly u need to change the last paramter as a single-item list of your desired aspect ratio for the rest 5 as well.

2. ~\pytorch-ssd\vision\utils\box_utils.py

Inside the function generate_ssd_priors, the author generates 2 square boxes + 2-variable-sized boxes of a given aspect ratio.
In-order for your code to work, comment out the small box and bigger-box and one of the variable-sized box.
Now you are left with just one anchor box.

3. ~pytorch-ssd\vision\ssd\mobilenet_v2_ssd_lite.py

In this file, there are two lists called classification_headers and regression_headers,
inside these two, you see a lot of conv2d layers, and in the out_channels parameters, there is something like (64num_channels) for regression_headers and (61num_channels) for classification_headers.
Replace the "6" with "1".
Thats it.

@gracecocks
Copy link

Was there ever an answer to how to train on negative images?

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

7 participants