/IM_Project

大戰資管專題

Primary LanguagePython

IM Special Reswearch

PyTorch Lightning Config: Hydra Template

Description

Code for run experiment of triplet classification

How to run

Install dependencies

# clone project
git clone https://github.com/dodofk/IM_Project
cd IM_Project

# [OPTIONAL] create conda environment
conda create -n myenv python=3.8
conda activate myenv

# install pytorch according to instructions
# https://pytorch.org/get-started/

# install requirements
pip install -r requirements.txt

# Setup timm with dev version
pip install git+https://github.com/rwightman/pytorch-image-models
# if now work, run this
cd src/vendor/pytorch-image-models 
pip install -e .

Dataset Setup

you should install requirements before download

# for downloading HeiChole Dataset
# it will download the preprocess dataset from downsample and resize image from the video
# the script might fail if download from drive is limited
bash scripts/download_cholect45.sh

if the above script is failed, you should download it from link manually

# after download the file, you should put it under folder of IM_Project
# and run the following script
mv CholecT45_resize.tar.gz data
cd data 
tar -xvf CholecT45_resize.tar.gz
mv CholecT45_resize CholecT45

Training

Train model with default configuration

For training in GPU, you might need to change configuration to fit in your GPU memory

ex: running experiment=triplet_attention_base you can find configuration file in /configs/experiment/triplet_attention_base.yaml

# train on CPU (our proposed model)
python train.py experiment=triplet_attention_base_cpu

# train on GPU (our proposed model)
python train.py experiment=triplet_attention_base

# train on GPU (our baselien model)
python train.py experiment=cholec_base