This project presents the code for the paper A 3D Reconstruction and Action Recognition Method for Construction Workers Using Voxel-Based Approach.
In the paper, a voxel-based approach for worker behavior recognition is proposed, which consists of four modules: detection, pose estimation, voxelization and classification. By transforming image data into structured voxel data, this project presents the concrete implementation of the method.
- Code and CAVC dataset is released. (2024.5)
Our project is based on a Windows10 system with a RTX 3060Ti GPU and python 3.7.12, and we remind you that python >= 3.7 is necessary. It support both GPU and CPU,but we recomend using GPU for convenience.
conda create -n my_env python=3.7
conda activate my_env
pip install -r requirments.txt
pip install vedo
git clone https://github.com/SuperCarry2001/Voxel-Based-ActionRecognition.git
Install suitable version CUDA.
conda install cudatoolkit==10.1 cudnn==7.6.0
Make sure pytorch and torchvision are installed on your python enviornment and suitable for your CUDA.
pip install git+https://github.com/mkocabas/yolov3-pytorch.git
pip install git+https://github.com/mkocabas/multi-person-tracker.git
Modify the paths of weights_path
and model_def
in yolo.py
, where the code would normally be located at:
package of yolov3-pytorch/yolov3/yolo.py
The package of yolov3-pytorch
above means the path you clone YOLOv3.
The Weights_path
is the path to weight-file of YOLOv3 which is trained on MOCS dataset.The model_def
is the path to yolov3-modified.cfg
which is in our repo.
Here we provide url, you should download and unzip them under the folder data/vibe_data
separately.
Replace the input file path
and output folder path
with your own path
cd to this repo
conda activate my_env
# Run on a local video
python demo_2voxel.py --input_file 'input file path' --output_folder 'output folder path'
python demo_2voxel.py --input_file ./images/demo.gif --output_folder ./result
Our dataset is open access for public, and you can download CAVC dataset via the link. Test set you can download here.
For data augmentation as shown in our paper, we provide code below.
python data_augmentation.py
Replace the 'your voxel file path'
with your own path
python vis-vox.py --file_path 'your voxel file path'
Replace the 'your voxel folder path'
with your own path
python batch_vis.py --folder_path 'your voxel folder path'
Running the code, and before that you should replace the path witn your own path.
python train.py
We release our trained weight file as best.pth
, you should replace its path in test.py
. You can use the code to calculate acc, recall and F1 score.
python test.py
Here are some great resources we benefit:
- YOLOv3 for detecting workers is from YOLOv3.
- MOCS for training YOLOv3 is from MOCS dataset.
- VIBE for regress worker's pose is from VIBE.
- SMPL for generate voxels is from SMPL.
- VEDO for visualization is from VEDO.