This document provides a step-by-step guide to install the necessary libraries, download the required models and config files, and execute the method for the SurgVU2024 Category-2 submission. You will also find instructions for exporting the model in a container for submission.
To begin, you need to clone the repository that contains the codebase for the project.
git clone https://github.com/quzanh1130/SurgVU2024-Category-2-Submission.git
cd SurgVU2024-Category-2-Submission
Our code is based on mmaction2. To run our code, you must install mmaction2.
On Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
On Arch Linux
sudo pacman -S ffmpeg
On MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
On Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
On Windows using Scoop (https://scoop.sh/)
scoop install ffmpeg
Using Anaconda
conda create --name openmmlab python=3.8 -y
conda activate openmmlab
# Install pytorch at: https://pytorch.org/get-started/locally/
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
pip install -U openmim
mim install mmengine
mim install mmcv==2.1.0
cd mmaction2
pip install -v -e .
First you need to create folder to store model
cd mmaction2
mkdir work_dirs
cd work_dirs
mkdir slowfast
If the model file is missing at mmaction2/work_dirs/slowfast/best_model.pth
, you can download it from the following Google Drive link:
If the config file is missing at mmaction2/configs/recognition/slowfast/slowfast_r101_8xb8-8x8x1-256e_rgb_1fps_video_final.py
, you can download it from the following Google Drive link:
To run the model and test your input video, execute the following steps:
-
Navigate to the directory where the process_testing.py file is located.
-
Run the script using the following command:
python process_testing.py
- After successful execution, the results will be saved in a JSON file at:
mmaction2/output/surgical-step-classification.json
To use different configurations or model checkpoints, modify the process_testing.py
file:
#Config and checkpoint
config_path = 'configs/recognition/slowfast/slowfast_r101_8xb8-8x8x1-256e_rgb_1fps_video_final.py'
checkpoint_path = 'work_dirs/slowfast/best_model.pth'
To test a different input video, modify the process_testing.py
file:
if __name__ == "__main__":
detector = SurgVUClassify()
video_file = detector.input_path / "vid_1_short.mp4" # Change your test video
detector.predict(str(video_file))
To prepare your submission, you will need to export the containerized application using Docker. If you don't have Docker installed, follow the links below for installation instructions:
Once Docker is installed, navigate to the mmaction2
directory and run the following command to export the container:
cd mmaction2
bash export.sh
After successful execution, a tarball of the container will be created at:
mmaction2/surgtoolloc_det.tar.gz
This file is your submission container.