Skip to content

quzanh1130/SurgVU2024-Category-2-Submission

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

SurgVU2024_Category-2-Submission

Instruction Overview

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.

Table of Contents

  1. Clone Repository
  2. Install Libraries
  3. Download Model and Config
  4. Running Method
  5. Export container

1. Clone Repository

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

2. Install Libraries

Our code is based on mmaction2. To run our code, you must install mmaction2.

2.1 Install ffmpeg for Video Processing:

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

2.2 Install Python Dependencies

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 .

3. Download Model and Config File

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:

4. Runing method

To run the model and test your input video, execute the following steps:

  1. Navigate to the directory where the process_testing.py file is located.

  2. Run the script using the following command:

python process_testing.py
  1. After successful execution, the results will be saved in a JSON file at:
 mmaction2/output/surgical-step-classification.json

4.1 Customizing Config and Model

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'

4.2 Testing a Different Video

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))

5. Export container

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:

  1. Install Docker on Ubuntu

  2. Install Docker on Window

Export Container

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.