Repo for final project for MIT 6.5940 TinyML and Efficient Deep Learning Computing
This project is based on Anomalies-by-Synthesis: Anomaly Detection using Generative Diffusion Models for Off-Road Navigation. This project proposes a multi-faceted optimization strategy tailored to the computational bottlenecks of the diffusion pipeline for anomaly detection.
The repo is built based on anomalies-by-synthesis.
Test environment: Run experiment/pipe_way.py.
Training
- training script:
diffunc/train/rugd_full_id_train.py
Inference
- inference script:
experiment/pipe_way.py - inference functions:
experiment/pipe.pyget_generated_imgfunction: perform guided diffusion to generate image- it calls
diffusion.p_sample_loopwherediffusionis a class ofGaussianDiffusion
Evaluation
- if it's your first time running the evaluation, run
experiment/freq_label.pyfirst - evaluation script:
experiment/eval_way.py - evaluation functions:
experiment/eval.py - diffusion inference (guided diffusion) functions:
diffunc/guided_diffusion.py
-
Install Git LFS.
-
Clone repository and
cdinto it.git clone --recursive https://github.com/siddancha/diffunc.git cd /path/to/diffunc -
Create a new Python virtual environment
python3 -m venv .venv --prompt=diffunc
-
Activate the virtual environment
source .venv/bin/activate -
Install pdm
pip install pdm
-
Install Python dependencies via pdm.
pdm install --no-isolation
-
Create the following symlink for
featup:ln -s `pwd`/.venv/lib/python3.10/site-packages/clip/bpe_simple_vocab_16e6.txt.gz .venv/lib/python3.10/site-packages/featup/featurizers/maskclip/
-
Create a folder (or symlinked folder) called
datainside thediffuncrepo.mkdir data
-
Download the RUGD dataset.
-
Unzip the downloaded files and structure the dataset as follows:
data/RUGD ├── RUGD_frames-with-annotations ├── creek, park-1, etc. -- folders for each scene containing ".png" files from the RGB camera. ├── RUGD_annotations ├── creek, park-1, etc. -- folders for each scene containing ".png" label color images, colored using the class palette. ├── RUGD_annotation-colormap.txt -- mapping containing a list of class id, class name and class color. -
Run the dataset conversion scripts.
./scripts/make_ddpm_train_set_rugd_full.py ./scripts/make_ddpm_train_set_rugd_trail_trail_15.py