Coder Social home page Coder Social logo

pyramidbox_pytorch's Introduction

A PyTorch Implementation of PyramidBox

PyramidBox: A Context-assisted Single Shot Face Detector.

Description

I train pyramidbox with pytorch and the result approaches the original paper result,the pretrained model can be downloaded in vgg,the final model can be downloaded in Pyramidbox.the AP in WIDER FACE as following:

Easy MAP Medium MAP hard MAP
origin paper 0.960 0.948 0.888
this repo 0.948 0.938 0.880

the AP in AFW,PASCAL,FDDB as following:

AFW PASCAL FDDB
99.65 99.02 0.983

the gap is small with origin paper,I train 120k batch_size 4 which is different from paper,which maybe cause the gap,if you have more gpu ,the final result maybe better.

Requirement

  • pytorch 1.3
  • opencv
  • numpy
  • easydict

Prepare data

  1. download WIDER face dataset
  2. modify data/config.py
  3. python tools/prepare_wider_data.py

Train

python main.py --batch_size 4  
		--lr 5e-4

Evalution

according to yourself dataset path,modify data/config.py

  1. Evaluate on AFW.
python tools/afw_test.py
  1. Evaluate on FDDB
python tools/fddb_test.py
  1. Evaluate on PASCAL face
python tools/pascal_test.py
  1. test on WIDER FACE
python tools/wider_test.py

Demo

you can test yourself image

python demo.py

Result

demo demo

References

pyramidbox_pytorch's People

Contributors

jianzhnie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pyramidbox_pytorch's Issues

您好,我运行demo.py的时候,显示如下,网上说batchsize太大,但是我找到不到运行demo.py调整batchsize的地方?

/home/lyl/anaconda3/envs/py1.3/bin/python /home/lyl/000_Code/pyramidbox_1.3/demo.py
Traceback (most recent call last):
File "/home/lyl/000_Code/pyramidbox_1.3/demo.py", line 113, in
detect(net, path, args.thresh)
File "/home/lyl/000_Code/pyramidbox_1.3/demo.py", line 73, in detect
y = net(x)
File "/home/lyl/anaconda3/envs/py1.3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/lyl/000_Code/pyramidbox_1.3/models/pyramidbox.py", line 173, in forward
ssh_conv3_norm = self.cpm0
File "/home/lyl/anaconda3/envs/py1.3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/lyl/000_Code/pyramidbox_1.3/models/pyramidbox.py", line 56, in forward
out_residual = self.branch1(x)
File "/home/lyl/anaconda3/envs/py1.3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/lyl/000_Code/pyramidbox_1.3/models/pyramidbox.py", line 35, in forward
return self.bn1(x)
File "/home/lyl/anaconda3/envs/py1.3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/lyl/anaconda3/envs/py1.3/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 81, in forward
exponential_average_factor, self.eps)
File "/home/lyl/anaconda3/envs/py1.3/lib/python3.6/site-packages/torch/nn/functional.py", line 1670, in batch_norm
training, momentum, eps, torch.backends.cudnn.enabled
RuntimeError: CUDA out of memory. Tried to allocate 322.00 MiB (GPU 0; 3.95 GiB total capacity; 2.90 GiB already allocated; 88.56 MiB free; 39.48 MiB cached)

Process finished with exit code 1

bug in demo.py

from pyramidbox import build_net
to
from models.pyramidbox import build_net

bug in demo.py

the flowing code is in your 'models.pyramidbox.py':

if not self.is_infer:
    output = (face_mbox_loc, face_mbox_conf,
                      head_mbox_loc, head_mbox_conf)
 else:
    output = self.detect(face_mbox_loc, self.softmax(face_mbox_conf))

but the function self.detect() needs three parameters in your script 'layers.functions.detection.py'

class Detect(Function):
    def __init__(self, cfg):
          ...
    def forward(self, loc_data, conf_data, prior_data):

so, when i run 'demo.py', the flowing error reported:

TypeError: forward() missing 1 required positional argument: 'prior_data'

运行demo.py时出错

你好,我成功的训练出了模型。但是在运行demo.py的时候出现了一个bug。

Traceback (most recent call last):
File "demo.py", line 117, in
detect(net, path, args.thresh)
File "demo.py", line 73, in detect
y = net(x)
File "/home/huyutao/anaconda3/envs/pytorch_gpu/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/huyutao/anaconda3/envs/pytorch_gpu/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 150, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/huyutao/anaconda3/envs/pytorch_gpu/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/huyutao/face_mask_detect/pyramidbox_pytorch/models/pyramidbox.py", line 262, in forward
self.softmax(face_mbox_conf))
TypeError: forward() missing 1 required positional argument: 'prior_data'

我查看了下源代码,是在pyramidbox.py中的261行。output = self.detect(face_mbox_loc, self.softmax(face_mbox_conf))少传了一个参数
Detect class貌似需要3个参数:loc_data, conf_data, prior_data;
请问下,prior_data这个参数如何传递?

如果我的理解有误,也请告知解决这个bug的方法。。。谢谢。

bug in train.py

criterion1(out, face_targets)
but criterion1 = MultiBoxLoss(cfg, args.cuda)
def forward(self, predictions, priors, targets):
"""Multibox Loss
need 3 args
TypeError: forward() missing 1 required positional argument: 'targets'

Problems in training

Hello, I have the following error when running the train.py file:
runtimeerror: expected a 'CUDA' device type for generator but found 'CPU'
How can I solve this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.