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

Adding link to Google drive for non Baidu users #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[A PyTorch Implementation of Dual Shot Face Detector](https://arxiv.org/abs/1810.10220?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+arxiv%2FQSXk+%28ExcitingAds%21+cs+updates+on+arXiv.org%29)

### Description
I use basenet [vgg](https://pan.baidu.com/s/1Q-YqoxJyqvln6KTcIck1tQ) to train DSFD,the model can be downloaded in [DSFD](https://pan.baidu.com/s/17cpDHEwYVxWmOIPqUy5zCQ).the AP in WIDER FACE as following:
I use basenet [vgg](https://pan.baidu.com/s/1Q-YqoxJyqvln6KTcIck1tQ) to train DSFD, the model can be downloaded in [DSFD with Baidu](https://pan.baidu.com/s/17cpDHEwYVxWmOIPqUy5zCQ) or [DSFD with Google Drive](https://drive.google.com/open?id=11pZy4DhslDP9cEk2uN9wNhTmB1VZ7GIR). The AP in WIDER FACE as following:

| Easy MAP | Medium MAP | hard MAP |
| ---------|------------| --------- |
Expand Down Expand Up @@ -68,4 +68,4 @@ python demo.py

### References
* [Dual Shot Face Detector](https://arxiv.org/abs/1810.10220?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+arxiv%2FQSXk+%28ExcitingAds%21+cs+updates+on+arXiv.org%29)
* [ssd.pytorch](https://github.com/amdegroot/ssd.pytorch)
* [ssd.pytorch](https://github.com/amdegroot/ssd.pytorch)
27 changes: 13 additions & 14 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
help='Directory for detect result')
parser.add_argument('--model',
type=str,
default='weights/dsfd_face.pth', help='trained model')
default='weights/dsfd_vgg_0.880.pth', help='trained model')
parser.add_argument('--thresh',
default=0.4, type=float,
help='Final confidence threshold')
Expand All @@ -58,10 +58,8 @@ def detect(net, img_path, thresh):

img = np.array(img)
height, width, _ = img.shape
max_im_shrink = np.sqrt(
1500 * 1000 / (img.shape[0] * img.shape[1]))
image = cv2.resize(img, None, None, fx=max_im_shrink,
fy=max_im_shrink, interpolation=cv2.INTER_LINEAR)
max_im_shrink = np.sqrt(1500 * 1000 / (img.shape[0] * img.shape[1]))
image = cv2.resize(img, None, None, fx=max_im_shrink,fy=max_im_shrink, interpolation=cv2.INTER_LINEAR)

x = to_chw_bgr(image)
x = x.astype('float32')
Expand All @@ -88,31 +86,32 @@ def detect(net, img_path, thresh):
j += 1
cv2.rectangle(img, left_up, right_bottom, (0, 0, 255), 2)
conf = "{:.2f}".format(score)
text_size, baseline = cv2.getTextSize(
conf, cv2.FONT_HERSHEY_SIMPLEX, 0.3, 1)
text_size, baseline = cv2.getTextSize(conf, cv2.FONT_HERSHEY_SIMPLEX, 0.3, 1)
p1 = (left_up[0], left_up[1] - text_size[1])
cv2.rectangle(img, (p1[0] - 2 // 2, p1[1] - 2 - baseline),
(p1[0] + text_size[0], p1[1] + text_size[1]),[255,0,0], -1)
cv2.putText(img, conf, (p1[0], p1[
1] + baseline), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (255, 255, 255), 1, 8)
cv2.rectangle(img, (p1[0] - 2 // 2, p1[1] - 2 - baseline),(p1[0] + text_size[0], p1[1] + text_size[1]),[255,0,0], -1)
cv2.putText(img, conf, (p1[0], p1[1] + baseline), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (255, 255, 255), 1, 8)

t2 = time.time()
print('detect:{} timer:{}'.format(img_path, t2 - t1))
print('Found:{}'.format(j))

cv2.imwrite(os.path.join(args.save_dir, os.path.basename(img_path)), img)


if __name__ == '__main__':
net = build_net('test', cfg.NUM_CLASSES, args.network)
net.load_state_dict(torch.load(args.model))
if use_cuda:
net.load_state_dict(torch.load(args.model))
else:
net.load_state_dict(torch.load(args.model, map_location=lambda storage, loc: storage))

net.eval()

if use_cuda:
net.cuda()
cudnn.benckmark = True

img_path = './img'
img_list = [os.path.join(img_path, x)
for x in os.listdir(img_path) if x.endswith('jpg')]
img_list = [os.path.join(img_path, x) for x in os.listdir(img_path) if x.endswith('jpg')]
for path in img_list:
detect(net, path, args.thresh)
2 changes: 1 addition & 1 deletion layers/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .prior_box import PriorBox
from detection import Detect
from .detection import Detect

__all__=['Detect','PriorBox']

1 change: 1 addition & 0 deletions weights/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Github does not allow files over 100MB. For this reason, please download the model on [Baidu](https://pan.baidu.com/s/17cpDHEwYVxWmOIPqUy5zCQ) or [Google](https://drive.google.com/open?id=11pZy4DhslDP9cEk2uN9wNhTmB1VZ7GIR) and place it here.