Skip to content

Commit

Permalink
update demos (open-mmlab#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-s13 authored Jul 23, 2020
1 parent b72d52f commit caa5253
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions demo/img_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def main():
if args.out_img_root == '':
out_file = None
else:
os.makedirs(args.out_img_root, exist_ok=True)
out_file = os.path.join(args.out_img_root, f'vis_{i}.jpg')

# show the results
Expand Down
1 change: 1 addition & 0 deletions demo/img_demo_with_mmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def main():
if args.out_img_root == '':
out_file = None
else:
os.makedirs(args.out_img_root, exist_ok=True)
out_file = os.path.join(args.out_img_root, f'vis_{args.img}')

# show the results
Expand Down
7 changes: 4 additions & 3 deletions demo/video_demo_with_mmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ def main():

cap = cv2.VideoCapture(args.video_path)

if args.out_video_root != '':
save_out_video = True
else:
if args.out_video_root == '':
save_out_video = False
else:
os.makedirs(args.out_video_root, exist_ok=True)
save_out_video = True

if save_out_video:
fps = cap.get(cv2.CAP_PROP_FPS)
Expand Down
27 changes: 13 additions & 14 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ We provide a demo script to test a single image, given gt json file.
python demo/image_demo.py \
${MMPOSE_CONFIG_FILE} ${MMPOSE_CHECKPOINT_FILE} \
--img-root ${IMG_ROOT} --json-file ${JSON_FILE} \
--show \
[--out-img-root ${OUTPUT_DIR} --device ${GPU_ID}] \
--out-img-root ${OUTPUT_DIR} \
[--show --device ${GPU_ID}] \
[--kpt-thr ${KPT_SCORE_THR}]
```

Expand All @@ -144,8 +144,7 @@ python demo/image_demo.py \
configs/top_down/hrnet/coco/hrnet_w48_coco_256x192.py \
hrnet_w48_coco_256x192/epoch_210.pth \
--img-root tests/data/ --json-file tests/data/test_coco.json \
--show \
--out-img-root ./
--out-img-root vis_results
```

#### Using mmdet for human bounding box detection
Expand All @@ -159,8 +158,8 @@ python demo/image_demo_with_mmdet.py \
${MMDET_CONFIG_FILE} ${MMDET_CHECKPOINT_FILE} \
${MMPOSE_CONFIG_FILE} ${MMPOSE_CHECKPOINT_FILE} \
--img-root ${IMG_ROOT} --img ${IMG_FILE} \
--show \
[--out-img-root ${OUTPUT_DIR} --device ${GPU_ID}] \
--out-img-root ${OUTPUT_DIR} \
[--show --device ${GPU_ID}] \
[--bbox-thr ${BBOX_SCORE_THR} --kpt-thr ${KPT_SCORE_THR}]
```

Expand All @@ -173,8 +172,7 @@ python demo/img_demo_with_mmdet.py mmdetection/configs/faster_rcnn/faster_rcnn_r
hrnet_w48_coco_256x192/epoch_210.pth \
--img-root tests/data/ \
--img 000000196141.jpg \
--show \
--out-img-root ./
--out-img-root vis_results
```

### Video demo
Expand All @@ -188,8 +186,8 @@ python demo/video_demo_with_mmdet.py \
${MMDET_CONFIG_FILE} ${MMDET_CHECKPOINT_FILE} \
${MMPOSE_CONFIG_FILE} ${MMPOSE_CHECKPOINT_FILE} \
--video-path ${VIDEO_FILE} \
--show \
[--output-video-root ${OUTPUT_VIDEO_ROOT} --device ${GPU_ID}] \
--output-video-root ${OUTPUT_VIDEO_ROOT} \
[--show --device ${GPU_ID}] \
[--bbox-thr ${BBOX_SCORE_THR} --kpt-thr ${KPT_SCORE_THR}]
```

Expand All @@ -201,8 +199,7 @@ python demo/video_demo_with_mmdet.py mmdetection/configs/faster_rcnn/faster_rcnn
configs/top_down/hrnet/coco/hrnet_w48_coco_256x192.py \
hrnet_w48_coco_256x192/epoch_210.pth \
--video_path demo/demo_video.mp4 \
--show \
--output-video-root ./
--output-video-root vis_results
```

## Train a model
Expand Down Expand Up @@ -264,10 +261,12 @@ If you can run MMPose on a cluster managed with [slurm](https://slurm.schedmd.co
./tools/slurm_train.sh ${PARTITION} ${JOB_NAME} ${CONFIG_FILE} ${WORK_DIR} [${GPUS}]
```

Here is an example of using 16 GPUs to train ResNet50 on the dev partition in a slurm cluster. (use `GPUS_PER_NODE=8` to specify a single slurm cluster node with 8 GPUs.)
Here is an example of using 16 GPUs to train ResNet50 on the dev partition in a slurm cluster.
(Use `GPUS_PER_NODE=8` to specify a single slurm cluster node with 8 GPUs, `CPUS_PER_TASK=2` to use 2 cpus per task.
Assume that `Test` is a valid ${PARTITION} name.)

```shell
GPUS_PER_NODE=8 ./tools/slurm_train.sh configs/top_down/resnet/coco/res50_coco_256x192.py work_dirs/res50_coco_256x192 16
GPUS_PER_NODE=8 CPUS_PER_TASK=2 ./tools/slurm_train.sh Test res50 configs/top_down/resnet/coco/res50_coco_256x192.py work_dirs/res50_coco_256x192 16
```

You can check [slurm_train.sh](../tools/slurm_train.sh) for full arguments and environment variables.
Expand Down

0 comments on commit caa5253

Please sign in to comment.