FetalGAN is a Python-based interface for training and inference across different architectures for deep learning supervised tasks, specialized in medical imaging such as fetal MRI. It provides a flexible, easy-to-use environment based on MONAI framework for rapid experimentation and reproducible research.
License: Apache License 2.0
- Modular interface for training and inference in supervised networks.
- Supports multiple architectures (e.g., GANs, U-Nets, etc.) and allow easy integration of your own architectures and losses (conditioning, diffusion model and deep supervision will be integrated soon; transformer architectures and additional advanced loss functions can be added).
- Easy modification between experiments as all management of the process is using .json.
- Pythonic API for integration with existing pipelines.
FetalGAN/
SELECT/
README.md
FetalGAN/: Main source code for all the training and inference process.SELECT/: Additional scripts that must be added after you create a project folder and in all the projects you create. Used to control the desired dataset, training and inference names and parameters.README.md: Project documentation and license.
Clone the repository:
git clone https://github.com/pedroalarcongil/FetalGAN.git
cd FetalGANCreate your own conda environment
conda create -name FetalGAN2 python==3.9Activate your desired conda environment
conda activate FetalGAN2Install the required dependencies (Python 3.8+ recommended):
pip install -e .Starts a project:
Activate the environment for this package
conda activate FetalGAN2
Move to different actions commands
cd ./FetalGAN/Scripts/
Define the path to build the structure where all training and inference processes will be saved
./Init.sh
Place in the generated SELECT path (/Root_path/SELECT/) the three files in the SELECT folder of this package called Dataset.json, Network.json and inference.json (these files will manage the different dataset, training and inference architectures and run parameters).
Create a dataset:
Configure the files you want to add in the dataset and the type of dataset you want depending on you want cross-validation or not. Available generation options to generate test/train splits, support for cross-validation and class balancing. It supports with different approachs to select the input and ground truth file paths.
Dataset configuration file is in /FetalGAN/Creator/Dataset.py
When you have selected your desired configuration for your dataset:
cd /FetalGAN/Scripts
./Dataset.sh
This dataset will be referenced throughout the process with the name you define in the dataset configuration file. The result is saved in /Rootpath/DATASETS/Dataset_Name/. In this folder will be the configuration, splits, and meta-information.
Create a preprocessor:
Configure the steps you want to add in the preprocessing in /FetalGAN/NETS/Creator/Preprocess.py.
Look at the current available steps and integrate your new steps in the file LoadedDA.py in folder /FetalGAN/NETS/Data/. The file designed to add your own preprocessing steps is Presteps.py in that folder.
When you have selected your desired configuration for the preprocessor:
cd /FetalGAN/Scripts
./Preprocessor.sh
You can create all the different preprocessing as you want or overwrite old preprocessing with the name you assign to the file. After generation, you can modify your preprocessing file in /Rootpath/NETS/Data/Presteps.py for custom specifications.
Create a training architecture:
Configure the networks, losses and optimizer you want to use in /FetalGAN/NETS/Creator/Network.py.
Look at current available networks, losses and optimizers and integrate your own creations in the file Benchmark.py in folder /FetalGAN/NETS/Options/. The file designed to add your own creations must follow the specified class structure and API conventions.
Start your trainings:
You must first change the variable path_selector inside /FetalGAN/NETS/train.py with the path of Network.json from the SELECTOR folder.
In Network.json you can define different parameters of the training like training name, GPU used, epochs (definition of epoch is when the training has seen all the images one time, it means that the end of epoch is the completion of a full pass through the dataset), batch size, optimizer settings, and advanced options.
When you have finished configuring your network, go to /FetalGAN/Scripts/ and run:
./Trainer.sh
Run inference:
You must first change the variable path_inference inside /FetalGAN/NETS/infer.py with the path of Inference.json from the SELECTOR folder.
Define the variables of inference.json with your own paths and parameters.
Go to /FetalGAN/Scripts and run:
./Inference.sh
- Python
- PyTorch
- Numpy, Scikit-learn
- MONAI
Contributions and suggestions are welcome! Please fork the project, create a feature branch, and open a pull request.
Developed by Pedro Pablo Alarcón Gil with the supervision of [Alena Uus], [Lucilio Cordero Grande] and [María Jesús Ledesma Carbayo] as part of Phd studies.
This project is licensed under the Apache License 2.0.
See the LICENSE file for details.
For questions, suggestions, or collaborations, please reach out through GitHub or email listed in your profile.
FetalGAN: Interface for train and inference different architectures for supervised segmentation in medical imaging. rent architectures for supervised segmentation in medical imaging.*