Sign inSign up

humanoidsctu/detectron2

By humanoidsctu

•Updated almost 3 years ago

Image
0

152

humanoidsctu/detectron2 repository overview

This image has been used for the paper: https://link.springer.com/article/10.3758/s13428-025-02816-x⁠ (free access to the pdf: https://rdcu.be/eFwac⁠) The Dockerfile can be found in the osf repository: https://osf.io/gy98b/⁠

⁠0. Prerequisite

The host computer must have the appropriate packages installed to allow GPUs to be used by the Docker containers, e.g., for Nvidia GPUs, it requires to install the Nvidia container toolkit: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html⁠⁠

All ready-to-use Docker containers (including this one), are constrained to the dependencies software versions they had when built. The main cause for compatibility issues and the container not working properly comes from the graphic card and the versions of CUDA/cudnn/Pytorch. In particular, any recent enough GPU that is not handled by the pre-installed version would lead to errors, or the images/videos not being processed. In such a case, the fix is to use the Dockerfile shared on our osf and modify the appropriate lines to use versions of the software. For example, using an Nvidia GPU RTX A4000 or A5000 requires to modify the Dockerfile to use CUDA version 11.3, and cudnn 8; then to rebuild a docker container using the updated Dockerfile.

⁠1. Docker build

Dockerfile based on the official Dockerfile from August 2022 https://github.com/facebookresearch/detectron2/tree/main/docker⁠

sudo docker build --build-arg USER_ID=$UID -t detectron2:paper .

⁠2. Docker startup

Default command: sudo docker run --rm --gpus all -it -e="DISPLAY" -v=/tmp/.X11-unix:/tmp/.X11-unix:rw -v /home/$user:/home/$user detectron2:paper /bin/bash

Replace $user by the session's username.

Add -v /media:/media to give access to external hard drives

If needed, limit the amount of RAM shared with docker with the parameter: --shm-size=8gb

⁠3. Processing commands for Detectron2:

Replace $data_path by the path to the data folder and $result_path by the path to the result folder

Warning: the folder to which the --output and --export are written must exist.

Add --output $result_path/detectron2/vis to save the images with the keypoints and skeleton on top. Necessitate to create the folder. Be careful that it should be added right after python demo/demo.py, if added at the end, detectron2 will throw an error.

Memory profiling can be done by adding the following command before the processing commands described below: mprof run --include-children --multiprocess --output $result_path/detectron2/mprofile.dat

⁠3.1 Processing .png images in a folder inside the Docker without visualizating results

python demo/demo.py --config-file configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml --input $data_path/images/*.png --export $result_path/detectron2/keypoints_coco17 --opts MODEL.WEIGHTS models/model_final_a6e10b.pkl

change .png for other formats if needed.

⁠3.2 Processing a video inside the Docker without visualizating results

python demo/demo.py --config-file configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml --video-input $data_path/$video --export $result_path/detectron2/keypoints_coco17 --opts MODEL.WEIGHTS models/model_final_a6e10b.pkl

Replace $video by the name of the video.

To avoid potential changes or unavailability of the file, and ensure reproduction of results the model weights were downloaded on 2023.01.11 from https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x/137849621/model_final_a6e10b.pkl as file model_final_a6e10b.pkl, added to the gitlab repository, and the local version is used to run Detectron2, rather than being always downloaded from facebook servers.

⁠4. Changes from the official github:

Based on the official files available here on August 2022: https://github.com/facebookresearch/detectron2/tree/main/demo⁠ On demo.py:

  • Rows 74-78 added option to specify export path
  • Row 109 added variable initialization
  • Rows 139-143, 190-194 commented to disable visualization
  • Rows 129-130, 185-189 added to export detections
  • Rows 198-199 commented to avoid errors due to disabled visualization On predictor.py:
  • Rows 67-68 added to save detections
  • Row 69 modified to return detections
  • Row 90 added dictionary inicialization
  • Rows 110-112 added to return detections

Tag summary

Content type

Image

Digest

sha256:c152bf183…

Size

9 GB

Last updated

almost 3 years ago

docker pull humanoidsctu/detectron2:paper