Skip to content

Code for my bachelorthesis on ui2i using cut and AdaAttn

License

Notifications You must be signed in to change notification settings

bratorange/CutAttn

Repository files navigation

Cloned from the cut repo

Contrastive Unpaired translation with style attention

This repo contains all the code used in my bachelor thesis, to train, test, and evaluate adding style adaptation to the cut model.

Getting started

  1. Create and activate the venv:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  1. Store a dataset under dataset.

  2. Training and testing is organized in experiments which are a collection of hyperparameters each. All experiments reside in launcher.py. They can be configured here and given an experiment_id. An experiment might look like this:

16: Options(
        name="resnet_atn_16_from_02_multiple_atn_spectral_norm",
        netG="resnet_atn",
        netD="basic_spectral_norm",
        ada_norm_layers="12,13",
        continue_train="",
        pretrained_name="baseline_14_start_spectral_norm",
        epoch=2,
        lr=0.00002,
    ),

Mostly these are the hyperparameters from cut with a few additions.

Choose an experiment and train it:

./launcher.py train 16
  1. When training is finished you can infere from a test split:
./launcher.py test_all 16

This will infere 50 images for every epoch trained.

  1. If you want to evaluate label preservation performance with a segmentation model, you have to train one first. In our work cholec8K segmentations were used.
./launcher.py train_seg test cholec8K
  1. After this is finished copy its weights from logs/cholec8K/version_0/checkpoints/some_name.ckpt to logs/weights/default.ckpt and run an evaluation on the images generated by cut:
./launcher.py eval_all cut 16
  1. Show the evaluation scores:
./launcher.py vis 16

Extra hyperparameters:

Hyperparameter Effect
no_random_mask Omit the oval mask on the image to mimic the tube occlusion on a laparoscope. This mask is added to counter domain missmatch.
netG Option from the base model. Additional networks resnet_adain or resnet_atn are available.
netD Option from the base model. Additional network basic_spectral_norm is available.
dataset_mode Option from the base model. Additional mode pretrain is available.
ada_norm_layers Comma seperated list of layer which will apply the style normalization. May only be used in conjunction with netG="resnet_adain" or netG="resnet_atn".

About

Code for my bachelorthesis on ui2i using cut and AdaAttn

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages