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

yolov3-spp.cfg Support #16

Closed
happog opened this issue Sep 21, 2018 · 10 comments
Closed

yolov3-spp.cfg Support #16

happog opened this issue Sep 21, 2018 · 10 comments

Comments

@happog
Copy link

happog commented Sep 21, 2018

Could you add support for yolov3-spp model? https://github.com/pjreddie/darknet/blob/master/cfg/yolov3-spp.cfg

@glenn-jocher
Copy link
Member

@happog I added yolov3-spp.cfg in commit b93839d. You just need to specify it in train.py before you start training now. I'm unfamiliar with the SPP variant, what does it do?

parser.add_argument('-cfg', type=str, default='cfg/yolov3.cfg', help='cfg file path')

@happog
Copy link
Author

happog commented Sep 21, 2018

@glenn-jocher Thank you for answering. SPP means spatial pyramid pooling. As the spp cfg needs the maxpool (stride=1) layer, so it should not work correctly if this layer is not implemented in the model.py file.

@glenn-jocher
Copy link
Member

@happog models.py correctly implements any of the following layers in any *.cfg file. If the SPP file only uses these existing types, then everything should be fine. If the SPP is introducing a new type of layer then there could be a problem (if it is not recognized it may be skipped). When I start training with SPP I see 3 new layers added, layer count goes from 221 to 224. How many layers are you expecting the SPP cfg to produce?

  • convolutional
  • batch_norm
  • upsample
  • route
  • shortcut
  • yolo

@nirbenz
Copy link

nirbenz commented Dec 19, 2018

@happog
@glenn-jocher

Re-opening this. I gave this a shot, trying to simply add support for a maxpool layer as it should be (in models.py):

        elif module_def['type'] == 'maxpool':
            stride = int(module_def['stride'])
            kernel_size = int(module_def['size'])
            pad = (kernel_size - 1) / 2
            maxpool_layer = nn.MaxPool2d(stride=stride, kernel_size=kernel_size, padding=pad)
            modules.add_module('maxpool_%d' % i, maxpool_layer)

And this indeed works, however network performance is actually significantly worse so I'm obviously doing something wrong.

@glenn-jocher glenn-jocher reopened this Dec 22, 2018
@glenn-jocher glenn-jocher changed the title request for support for yolov3-spp cfg file yolov3-spp.cfg Support Dec 22, 2018
@glenn-jocher
Copy link
Member

glenn-jocher commented Dec 22, 2018

I added support for yolov3-tiny using the maxpool layer (and implementing a fix to the routing layer, and modifying the stride calculation in models.py yolo forward) in #51, so if yolov3-spp was suffering from issues before perhaps these are now resolved as well. I'll try to run inference with yolov3-spp and see the result now:

python3 detect.py --cfg cfg/yolov3.cfg --weights weights/yolov3.weights
dog
zidane

python3 detect.py --cfg cfg/yolov3-spp.cfg --weights weights/yolov3-spp.weights
dog
zidane

Ok, results look comparable to yolov3. Well SPP certainly seems to be working, though this limited anecdotal evidence makes it hard to conclude whether it represents an improvement over standard yolov3, or if there are pytorch implementation issues. To resolve implementation issues I must compare against darknet directly. I'll try that now. Hmm, ok still inconclusive.

./darknet detect cfg/yolov3.cfg yolov3.weights data/...
predictions
predictions

./darknet detect cfg/yolov3-spp.cfg yolov3-spp.weights data/...
predictions
predictions

Strangely enough tie used to get 1.00 also using the repo originally.
zidane_result

@LukeAI
Copy link
Contributor

LukeAI commented May 2, 2019

What was the conclusion here? Does Yolov3-SPP work now with reasonable performance and precision?

@glenn-jocher
Copy link
Member

@LukeAI works perfectly. Yolov3-SPP is the default model for all operations now in train.py, detect.py and test.py. It acheives .607 mAP as you can see: https://github.com/ultralytics/yolov3#map.

@LukeAI
Copy link
Contributor

LukeAI commented May 2, 2019

Ah yes, thankyou! Why do you think this repo. achieves slightly higher accuracy?

@sanazss
Copy link

sanazss commented Jul 19, 2019

should we use yolove-1cls or yolov3-spp-1cls for single class and image size of 512*512? does it make difference? all default size in the code is 416 which is in yolov3-1cl

@glenn-jocher
Copy link
Member

@sanazss yolov3-spp-1cls.cfg will give you better results for training single class models.

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

5 participants