Skip to content

Commit

Permalink
update readme and run_webcam bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliangXiu committed Mar 10, 2019
1 parent 9ffe788 commit 1a88688
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 70 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
*/.ipynb_checkpoints/*
*.t7
*.jpg
*.png
*.txt
!requirements.txt
*.pyc
models
results
__pycache__
others
.vscode
.pycocotools
.idea
pretrained
*.pth
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@ Some codes for networks and display are brought from:
2. [Vanilla FCN, U-Net, SegNet, PSPNet, GCN, DUC](https://github.com/zijundeng/pytorch-semantic-segmentation)
3. [Shufflenet-v2-Pytorch](https://github.com/ericsun99/Shufflenet-v2-Pytorch)
4. [tf-pose-estimation](https://github.com/ildoonet/tf-pose-estimation)
5. [DSNTNN](https://github.com/anibali/dsntnn)
5. [dsntnn](https://github.com/anibali/dsntnn)

## NEWS!

- Mar 2019: Support running on MacBook with decent FPS!
- Feb 2019: **ALL** the pretrained model files are avaliable!

## Requirements

- Python 3.6
- Python 3.7
- PyTorch 1.0
- DSNTNN 1.0
- [dsntnn 1.0](https://github.com/anibali/dsntnn)

## Evaluation Results

|Model|Parmas(M)|Flops(G)|mAP(IoU=0.5:0.95)|mAP(IoU=0.5)|mAR(IoU=0.5:0.95)|mAR(IoU=0.5)|Google Drive|
|---|---|---|---|---|---|---|---|
|ResNet18(224x224)+DUC+DSNTNN|12.26|1.64|**0.682**|0.939|**0.797**|0.967|[50M](https://drive.google.com/open?id=17Z1zetIVDI4_8-ZoFgTRsjHtDpwGtjRT)|
|MobileNetV2(224x224)+DUC+DSNTNN|3.91|0.49|0.675|**0.949**|0.794|**0.971**|[16M]([https://drive.google.com/open?id=1Meyz8Jg2aRe8ijeBAY1uCRpV9l5OJoXl](https://drive.google.com/open?id=15Ihv1bVQv6_tYTFlECJMNrXEmrrka5g4))|
|ShuffleNetV2(224x224)+DUC+DSNTNN|2.92|**0.31**|0.615|0.916|0.748|0.955|[12M](https://drive.google.com/open?id=184Zg4E6HbbizPFYcELMXCd7mwWXdUd3U)|
|SqueezeNet1.1(224x224)+DUC+DSNTNN|**2.22**|0.63|0.584|0.921|0.723|0.958|[9M](https://drive.google.com/open?id=1RePeiBJHeHvmYTQ5vAUJHC5CstHIBcP0)|
|Model(+DUC+DSNTNN)|Parmas(M)|Flops(G)|AP@0.5:0.95|AP@0.5|AR@0.5:0.95|AR@0.5|Link|
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|ResNet18|12.26|1.64|**68.2**|93.9|**79.7**|96.7|[51.5M](https://drive.google.com/open?id=17Z1zetIVDI4_8-ZoFgTRsjHtDpwGtjRT)|
|MobileNetV2|3.91|0.49|67.5|**94.9**|79.4|**97.1**|[16.6M](https://drive.google.com/open?id=15Ihv1bVQv6_tYTFlECJMNrXEmrrka5g4)|
|ShuffleNetV2|2.92|**0.31**|61.5|91.6|74.8|95.5|[12.4M](https://drive.google.com/open?id=184Zg4E6HbbizPFYcELMXCd7mwWXdUd3U)|
|SqueezeNet1.1|**2.22**|0.63|58.4|92.1|72.3|95.8|[9.3M](https://drive.google.com/open?id=1RePeiBJHeHvmYTQ5vAUJHC5CstHIBcP0)|

<div align="center">
<img src="./demo.png">
Expand All @@ -39,19 +44,23 @@ Some codes for networks and display are brought from:

## Usage

1. Training:
1. Installation:

```shell
pip install -r requirements.txt
```
2. Training:
```shell
python training.py --model shufflenetv2 --gpu 0 --inputsize 224 --lr 1e-3 --batchsize 128 --t7 ./models/shufflenetv2_224_adam_best.t7
```
2. Evaluation
3. Evaluation
```shell
ln -s cocoapi/PythonAPI/pycocotools
cd cocoapi/PythonAPI && make

python eval.py --t7 ./models/resnet18_224_adam_best.t7 --model resnet18 --gpu 0
```

3. Web Camera Demo
4. Web Camera Demo (MacBook)

```shell
python run_webcam.py --model squeezenet --inp_dim 224 --camera 0
Expand Down
9 changes: 5 additions & 4 deletions coco_utils.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
'''
File: coco_utils.py
Project: MobilePose
File Created: Saturday, 3rd March 2018 7:04:57 pm
Project: MobilePose-PyTorch
File Created: Thursday, 20th December 2018 6:11:07 pm
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Thursday, 8th March 2018 3:02:15 pm
Last Modified: Monday, 11th March 2019 12:51:27 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2018 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''



# define coco class
import json
import numpy as np
Expand Down
17 changes: 5 additions & 12 deletions dataloader.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'''
File: dataloader.py
Project: MobilePose
File Created: Thursday, 8th March 2018 3:00:27 pm
Project: MobilePose-PyTorch
File Created: Tuesday, 15th January 2019 6:26:25 pm
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Thursday, 8th March 2018 3:00:39 pm
Last Modified: Monday, 11th March 2019 12:51:19 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2018 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''


import csv
import numpy as np
import os
Expand Down Expand Up @@ -162,14 +163,6 @@ def __call__(self, sample):
# guass_heatmap = sample['guass_heatmap']
h, w = image.shape[:2]

# x_mean = np.mean(image[:,:,3])
# x_std = np.std(image[:,:,3])
# y_mean = np.mean(image[:,:,4])
# y_std = np.std(image[:,:,4])

# mean=np.array([0.485, 0.456, 0.406, x_mean, y_mean])
# std=np.array([0.229, 0.224, 0.225, x_std, y_std])

mean=np.array([0.485, 0.456, 0.406])
std=np.array([0.229, 0.224, 0.225])

Expand Down
20 changes: 13 additions & 7 deletions dataset_factory.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
'''
File: dataset_factory.py
Project: MobilePose-PyTorch
File Created: Sunday, 10th March 2019 8:02:12 pm
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Monday, 11th March 2019 12:51:11 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''


from dataloader import Rescale, Wrap, PoseDataset, ToTensor, Augmentation, Expansion
from torchvision import datasets, transforms, utils, models
import os
Expand All @@ -12,14 +25,7 @@ def get_transform(modeltype, input_size):
:param input_size:
:return:
"""
# if "resnet" in modeltype:
# return Rescale((input_size, input_size))
# elif "mobilenet" in modeltype:
# return Wrap((input_size, input_size))
# else:
# raise ValueError("modeltype is not wrong")
return Rescale((input_size, input_size))
# return Wrap((input_size, input_size))


class DatasetFactory:
Expand Down
Binary file added demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions estimator.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'''
File: estimator.py
Project: MobilePose
File Created: Thursday, 8th March 2018 3:02:01 pm
Project: MobilePose-PyTorch
File Created: Monday, 11th March 2019 12:50:16 am
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Thursday, 8th March 2018 3:02:06 pm
Last Modified: Monday, 11th March 2019 12:50:58 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2018 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''


import itertools
import logging
import math
Expand Down
9 changes: 5 additions & 4 deletions eval.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# coding: utf-8
'''
File: eval.py
Project: MobilePose
File Created: Thursday, 8th March 2018 1:54:07 pm
Project: MobilePose-PyTorch
File Created: Thursday, 7th March 2019 1:50:18 pm
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Thursday, 8th March 2018 3:01:51 pm
Last Modified: Monday, 11th March 2019 12:50:50 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2018 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''


import warnings
warnings.filterwarnings('ignore')

Expand Down
11 changes: 6 additions & 5 deletions network.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
'''
File: networks.py
Project: MobilePose
File Created: Thursday, 8th March 2018 2:59:28 pm
File: network.py
Project: MobilePose-PyTorch
File Created: Thursday, 7th March 2019 6:33:57 pm
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Thursday, 8th March 2018 3:01:29 pm
Last Modified: Monday, 11th March 2019 12:50:40 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2018 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''



from networks import *
from networks.senet import se_resnet
import torch.nn as nn
Expand Down
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
numpy==1.14.5
matplotlib==3.0.2
scipy==1.1.0
Cython==0.29.2
dsntnn==0.4.0a0
torch==1.0.0
alog==0.9.13
tqdm==4.19.9
imgaug==0.2.7
torch==1.0.0
scipy==1.1.0
scikit_image==0.13.1
opencv_python==3.4.2.17
tqdm==4.19.9
numpy==1.14.5
torchvision==0.2.1
Cython==0.29.2
dsntnn==0.4.0a0
imgaug==0.2.7
matplotlib==3.0.2
Pillow==5.4.1
scripts==2.0
skimage==0.0
10 changes: 5 additions & 5 deletions run_webcam.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'''
File: run_webcam.py
Project: MobilePose
File Created: Thursday, 8th March 2018 2:19:39 pm
Project: MobilePose-PyTorch
File Created: Monday, 11th March 2019 12:47:30 am
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Thursday, 8th March 2018 3:01:35 pm
Last Modified: Monday, 11th March 2019 12:48:49 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2018 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''

import argparse
Expand Down Expand Up @@ -48,7 +48,7 @@
# initial the camera
cam = cv2.VideoCapture(args.camera)

# ret_val, image = cam.read()
ret_val, image = cam.read()
image = crop_camera(image)

while True:
Expand Down
10 changes: 5 additions & 5 deletions training.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# coding: utf-8

'''
File: training.py
Project: MobilePose
File Created: Thursday, 8th March 2018 2:50:11 pm
Project: MobilePose-PyTorch
File Created: Friday, 8th March 2019 6:53:13 pm
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Thursday, 8th March 2018 2:50:51 pm
Last Modified: Monday, 11th March 2019 12:50:27 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2018 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''


# remove warning
import warnings
warnings.filterwarnings('ignore')
Expand Down
13 changes: 13 additions & 0 deletions utils/joint_transforms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
'''
File: joint_transforms.py
Project: MobilePose-PyTorch
File Created: Monday, 7th January 2019 1:25:58 pm
Author: Yuliang Xiu ([email protected])
-----
Last Modified: Monday, 11th March 2019 12:51:40 am
Modified By: Yuliang Xiu ([email protected]>)
-----
Copyright 2018 - 2019 Shanghai Jiao Tong University, Machine Vision and Intelligence Group
'''


import math
import numbers
import random
Expand Down

0 comments on commit 1a88688

Please sign in to comment.