Git Product home page Git Product logo

style-match-mitosis-detection's Introduction

Style Match for Mitotic Figure Detection

Repository for "Style Match: Reducing the Scanner Induced Domain Gap in Mitosis Detection using Style Transfer Alignment".


Setup

Requirements

  • Python >= 3.8
  • pip install -r requirements.txt

Data

Usage

  • Pretrained weights can be downloaded here.

Style Transfer Demo Notebook

Style Transfer

  • Train:
    • Content images from scanner 1 and style images from scanner 4:
    python train_style_transfer_midog.py --gpus 1 --precision 16 --max_steps 80000 \
    --data.batch_size 16 --data.data_path data/midog --data.content_scanners 1 \
    --data.style_scanners 4 --model.use_bfg True --model.use_skip True \
    --check_val_every_n_epoch 100
    
    • Content and style images from all scanners:
    python train_style_transfer_midog.py --gpus 1 --precision 16 --max_steps 80000 \
    --data.batch_size 16 --data.data_path data/midog --data.content_scanners "[1,2,3,4]" \
    --data.style_scanners "[1,2,3,4]" --model.use_bfg True --model.use_skip True \
    --check_val_every_n_epoch 100
    
    • Content images from COCO and style images from WikiArt:
    python train_style_transfer.py --gpus 1 --precision 16 --max_steps 80000 \
    --data.batch_size 16  --data.resize_size 512  --data.content_path data/coco/ \
    --data.style_path data/wikiart/ --model.use_skip True --model.use_bfg True \
    --val_check_interval 5000
    
  • Evaluation:
    • SSIM for model trained with content images from scanner 1 and style images from scanner 4:
    python test_style_transfer_midog.py --gpus 1 --precision 16 \
    --data.content_scanners 1 --data.style_scanners 4 \
    --checkpoint weights/adain_bfg_skip_c1_s4.ckpt
    

Classification

  • Train:
    • Scanner classification:
    python train_classifier.py --gpus 1 --precision 16 --max_epochs 5 \
    --data.data_path data/midog
    
  • Evaluation:
    • On validation set:
    python test_classifier.py --gpus 1 --precision 16 --data.data_path data/midog \
    --checkpoint weights/classifier.ckpt
    
    • On validation set augmented by style transfer model:
    python test_classifier.py --gpus 1 --precision 16 --data.data_path data/midog \
    --data.style_scanner 4 --model.style_checkpoint weights/adain_bfg_skip_c1_s4.ckpt \
    --checkpoint weights/classifier.ckpt
    

Detection

  • Train:
    • Standard:
    python train_detector.py --gpus 1 --precision 16 --max_epochs 100 --model.schedule step \
    --model.steps "[50]" --data.data_path data/midog --data.ann_path data/MIDOG.json \
    --data.train_scanners 1 --data.val_scanners 1
    
    • Style Match:
    python train_detector.py --gpus 1 --precision 16 --max_epochs 100 --model.schedule step \
    --model.steps "[50]" --data.data_path data/midog --data.ann_path data/MIDOG.json \
    --data.train_scanners 1 --data.val_scanners 1 --data.style_scanner 2 \
    --model.style_checkpoint weights/all_scanners.ckpt
    
    • FDA:
    python train_detector.py --gpus 1 --precision 16 --max_epochs 100 --model.schedule step \
    --model.steps "[50]" --data.data_path data/midog --data.ann_path data/MIDOG.json \
    --data.train_scanners 1 --data.val_scanners 1 --data.style_scanner 2 --data.fda_beta 0.01
    
    • STRAP:
    python train_detector.py --gpus 1 --precision 16 --max_epochs 100 --model.schedule step \
    --model.steps "[50]" --data.data_path data/midog --data.ann_path data/MIDOG.json \
    --data.random_style_path data/wikiart/ --data.train_scanners 1 --data.val_scanners 1 \
    --model.style_checkpoint weights/random_style.ckpt
    
    • Stain Normalization:
      • Apply stain normalization to the MIDOG dataset set by first running python scripts/stain_normalization -i data/midog -o data/normalizaed.
    python train_detector.py --gpus 1 --precision 16 --max_epochs 100 --model.schedule step \
    --model.steps "[50]" --data.data_path data/normalized --data.ann_path data/MIDOG.json \
    --data.train_scanners 1 --data.val_scanners 1
    
  • Evaluation:
    • Standard:
    python test_detector.py --gpus 1 --precision 16 --data.data_path data/midog/ \
    --data.ann_path data/MIDOG.json --checkpoint weights/reg_s1.ckpt --data.test_scanners 3 \
    --model.eval_only_positives true
    
    • Style Match:
    python test_detector.py --gpus 1 --precision 16 --data.data_path data/midog/ \
    --data.ann_path data/MIDOG.json --checkpoint weights/st_s1.ckpt --data.test_scanners 3 \
    --model.eval_only_positives true --data.style_scanners 2 \
    --model.style_checkpoint weights/all_scanners.ckpt
    
    • FDA:
    python test_detector.py --gpus 1 --precision 16 --data.data_path data/midog/ \
    --data.ann_path data/MIDOG.json --checkpoint weights/fda_s1.ckpt --data.test_scanners 3 \
    --model.eval_only_positives true --data.style_scanners 2 --data.fda_beta 0.01 \
    --data.workers 0
    
    • STRAP:
    python test_detector.py --gpus 1 --precision 16 --data.data_path data/midog/ \
    --data.ann_path data/MIDOG.json --data.random_style_path data/wikiart/ \
    --checkpoint weights/rand_s1.ckpt --data.test_scanners 3  --model.eval_only_positives true \
    --model.style_checkpoint weights/random_style.ckpt
    
    • Stain Normalization:
    python test_detector.py --gpus 1 --precision 16 --data.data_path data/normalized/ \
    --data.ann_path data/MIDOG.json --checkpoint weights/norm_s1.ckpt --data.test_scanners 3 \
    --model.eval_only_positives true --data.style_scanners 2 \
    --model.style_checkpoint weights/all_scanners.ckpt
    

style-match-mitosis-detection's People

Contributors

bwconrad avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.