This repository contains a Vivit fine-tuning project on medical data.
- A
.secretsfile must be placed in the repo's root directory to store your wandb API key. - The
srcdirectory contains the main codebase, while thescriptsdirectory contains scripts for running the project. - The
configsdirectory contains configuration files for the project. - Set up the dataset directory and update the configuration at
src/scripts/configs/config.yamlaccordingly. - The wandb project integration is pending (#TODO).
! WARNING: This container is discontiued, use the Accelerate container instead since it can run both single and multi GPU.
To run the script using the Accelerate container on HSSH, use the following command:
submit \
--name vivit-contrastive \
--gpus N \
--host hssh2 \
--mount "$(pwd)":/scratch/catdx \
--mount /home/vitturini/shared/RVENetCropRszMp4:/scratch/catdx/RVENetCropRszMp4 \
eidos-service.di.unito.it/vitturini/vivit:accelerateThe script will use by default every GPU allocated to the container, everything else is the same as the Python container.
Run the development container on HSSH using:
submit \
--name vivit-dev \
--gpus N \
--mount /mnt/fast-scratch/vitturini/catdx:/scratch/catdx \
--mount /home/vitturini/shared/fix_apical4:/scratch/catdx/fix_apical4 \
eidos-service.di.unito.it/vitturini/vivit:devCheck which machine your devcontainer is running on:
docker service ps my_containerWhen finished, scale the container down:
docker service scale my_container=0To reconnect (scale up) with the devcontainer:
docker service scale my_container=1To run the multi-gpu training script from inside the container:
accelerate launch -m src.scripts.mainYou can add arguments to the accelerate launch command, for example:
accelerate launch --num_processes 1 --mixed_precision fp16 -m src.scripts.main! WARNING: This container is not yet functional. It is a work in progress and should not be used for now.
To build the container, run the following command:
docker build -t eidos-service.di.unito.it/vitturini/vivit:base -f docker/Dockerfile_base .To push the container to the repository, use:
docker push eidos-service.di.unito.it/vitturini/vivit:baseTo make the code work as it is, the dataset must be in the following format: a dir with every video and a csv file with the labels.
dataset/
|-- video1.mp4
|-- video2.mp4
...
|-- videoN.mp4
|-- all_files_with_partition.csv
The csv file must contain the following columns:
- file_name: the name of the video file with the extension (e.g., video1.mp4)
- CO: the label for the CO
- Every other label
- partition: the partition of the video (train, val, test)
Nevertheless, the code uses the Huggingface Datasets library, so it is possible to use any dataset format supported by the library with a limited amount of work.
- A refactoring of the code is scheduled soon.
- The sweep container mounts the source code, so code should not be modified from anywhere when running the sweep.