medigan is a modular open-source Python library that provides an interface to multiple generative models and automates synthetic dataset generation.
Project description
WELCOME TO MEDIGAN
medigan - A Modular Python Library For Automating Synthetic Dataset Generation.
While being extendable to any modality and generative model, medigan focuses on automating medical image dataset synthesis using GANs for training deep learning models.
Documentation
Link to Documentation: https://medigan.readthedocs.io/en/latest/
Generative Models
The metadata and links to the models in medigan are stored in: https://github.com/RichardObi/medigan-models
Architectural Overview
Usage & Core Features:
- Researchers and ML-practitioners can conveniently use an existing model in `medigan` for synthetic data augmentation instead of having to train their own generative model each time.
- Users can search and find a model using search terms (e.g. "Mammography, 128x128, DCGAN") or key value pairs (e.g. `key` = "modality", `value` = "Mammography")
- Users can explore the config and information (metrics, use-cases, modalities, etc) of each model in `medigan`
- Users can generate samples using a model
- Users can also get the generate_method of a model that they may want to use dynamically inside their dataloaders
How to Add New Models to medigan:
- `medigan` motivates the reuse of trained generative models.
- Models can be added via pull request by adding a model to the config in https://github.com/RichardObi/medigan-models (link stored in `medigan.constants.CONFIG_FILE_URL`).
- Model contributors need to specify a link to their model package in the config. We recommend to host and link model packages on Zenodo. Reasons:
- Zenodo model packages get a static DOI. This provides clarity as to who the contributors and IP owners of each generative model in `medigan` are.
- File modification/updates under the same DOI are not possible in Zenodo. This helps to avoid security issues as package content remains static after the model is tested, verified, and added to `medigan`.
- Examples of how `medigan` model packages should be hosted on Zenodo can be found here: https://doi.org/10.5281/zenodo.5187715 and here: https://doi.org/10.5281/zenodo.5188558
Example code snippets
pip install medigan
# import medigan and initialize Generators
from medigan import Generators
generators = Generators()
# generate 10 samples using one of the medigan models
generators.generate(model_id="00001_DCGAN_MMG_CALC_ROI",
num_samples=10)
# get the model's generate method and run it to generate 3 samples
gen_function = generators.get_generate_function(model_id="00001_DCGAN_MMG_CALC_ROI",
num_samples=3)
gen_function()
# create a list of search terms and find the models that have these terms in their config.
values_list = ['dcgan', 'Mammography', 'inbreast']
models = generators.find_matching_models_by_values(values=values_list,
target_values_operator='AND',
are_keys_also_matched=True,
is_case_sensitive=False)
print(f'Found models: {models}')
# create a list of search terms, find a model and generate
values_list = ['dcgan', 'mMg', 'ClF', 'modalities', 'inbreast']
generators.find_model_and_generate(values=values_list,
target_values_operator='AND',
are_keys_also_matched=True,
is_case_sensitive=False,
num_samples=5)
# rank the models by a performance metric and return ranked list of models
ranked_models = generators.rank_models_by_performance(metric="SSIM",
order="asc")
print(ranked_models)
# find the models, then rank them by a performance metric and return ranked list of models
ranked_models = generators.find_models_and_rank(values=values_list,
target_values_operator='AND',
are_keys_also_matched=True,
is_case_sensitive=False,
metric="SSIM",
order="asc")
print(ranked_models)
# find the models, then rank them, and then generate samples with the best ranked model.
generators.find_models_rank_and_generate(values=values_list,
target_values_operator='AND',
are_keys_also_matched=True,
is_case_sensitive=False,
metric="SSIM",
order="asc",
num_samples=5)
# find all models that contain a specific key-value pair in their model config.
key = "modality"
value = "Full-Field Mammography"
found_models = generators.get_models_by_key_value_pair(key1=key,
value1=value,
is_case_sensitive=False)
print(found_models)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
medigan-0.0.1.tar.gz
(23.6 kB
view details)
Built Distribution
medigan-0.0.1-py3-none-any.whl
(27.4 kB
view details)
File details
Details for the file medigan-0.0.1.tar.gz
.
File metadata
- Download URL: medigan-0.0.1.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cf72690c0b174af7bedb42f728fec31f2d8333b98391e79a658d3dbea8b2264 |
|
MD5 | 40adfde6f9dd22153c3152ef71e7ceb1 |
|
BLAKE2b-256 | 1ac4943e56e77d663663f6dc741dcbe0594d574e318876824f04338ee1a68e93 |
File details
Details for the file medigan-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: medigan-0.0.1-py3-none-any.whl
- Upload date:
- Size: 27.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 337098c136b984edd87e1b473f2c77068fb7f9da9a57efb296ff01a971bfbfb6 |
|
MD5 | 44299dbd158866749f74a590ff823bb1 |
|
BLAKE2b-256 | 92483600c0e333eab8ac61e44796cccb05f390cdc44e66b2931b01e5889bf85a |