▄▄
▄▄█▀▀▀█▄█ ██ ▀███▄ ▀███▀ ▀███
▄██▀ ▀█ ▄██▄ ███▄ █ ██
██▀ ▀ ▄█▀██▄ █ ███ █ ▄██▀██▄ ██ ▄██▀██▄ ▄██▀███▄██▀██ ▄██▀██▄▀████████▄▀██▀ ▀██▀
██ ▄█ ▀██ █ ▀██▄ █ ██▀ ▀██ ██ ██▀ ▀████ ▀▀█▀ ██ ██▀ ▀██ ██ ▀██ ██ ▄█
██▄ ▀████ ████████ █ ▀██▄█ ██ ██ ██ ██ ██▀█████▄█ ██ ██ ██ ██ ██ ▄█
▀██▄ ██ █▀ ██ █ ███ ██▄ ▄██ ██ ██▄ ▄███▄ ███▄ ▄██▄ ▄██ ██ ▄██ ███
▀▀███████▄███▄ ▄████▄███▄ ██ ▀█████▀ ▄████▄ ▀█████▀ ██████▀█████▀ ▀█████▀ ██████▀ ▄█
██ ▄█
▄████▄ ██▀
A simple GAN to generate synthetic colorectal images with the associated mask, based on pix2pix architecture
Some examples:
- Clone this repository and enter it:
git clone https://github.com/WalBouss/GANoloscopy.git cd GANoloscopy
- Set up the environment:
- Use Anaconda to creat a python environment:
- Run
conda env create --name myenv
- Run
- Install Pytorch:
- Run
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
- Run
- Install dependencies with pip
- Install some other packages:
# Cython needs to be installed before pycocotools pip install wandb pip install opencv-python pillow pycocotools matplotlib
- Install some other packages:
- Use Anaconda to creat a python environment:
- Download the pretrain weights from here and place the file in the
./weight
folder.
To generate a synthetic dataset edit and run the following command (don't forget to put the pretrained weight is already in ./weight
dir):
# Specify the lenght and where to save the generated dataset.
python generate_synthetic_dataset.py --dataset_length=100 --path_to_save_img=path/dir/imgs --path_to_save_msk=path/dir/msks
# Use the help option to see a description of all available command line arguments
python generate_synthetic_dataset.py --help
To eval edit and run the following command
# Process a whole folder of masks.
python eval.py --path_to_masks=path/to/masks/ --path_to_save=path/to/save/data --batch_size=10
# Use the help option to see a description of all available command line arguments
python eval.py --help
To train edit and run the following command
# Trains
python train.py --path_data_train=path_to_training_data --batch_size=10 --epochs=250
# Use the help option to see a description of all available command line arguments
python train.py --help
GANoloscopy uses Weights & Biases library to visualize training and validation information by default.
You can also train on your own dataset by following organizing your data as follow:
.
├── dir
│ ├── images
│ └── masks
If you use GANoloscopy or this code base in your work, please cite
@article{Bousselham-GANoloscopy-2021,
author = {Walid Bousselham},
url = {https://github.com/WalBouss/GANoloscopy/}
title = {GANoloscopy: Generate colon images to enhance colonoscopies},
year = {2021},
}
For questions about the code, please contact Walid Bousselham.