# -*- coding: utf-8 -*-
from distutils.core import setup

packages = \
['segmed', 'segmed.metrics', 'segmed.models', 'segmed.train', 'segmed.utils']

package_data = \
{'': ['*']}

install_requires = \
['scikit-image>=0.16.2,<0.17.0',
 'scikit-learn>=0.21.3,<0.22.0',
 'tensorflow>=2.0,<3.0']

setup_kwargs = {
    'name': 'segmed',
    'version': '0.6.12',
    'description': 'Applying Deep Learning to medical image segmentation tasks',
    'long_description': '# SegMed [![Build Status](https://travis-ci.org/DCI-NET/segmed.svg?branch=master)](https://travis-ci.org/DCI-NET/segmed)\n\nThis is a collection of Deep Learning semantic segmentation models to use for\nspecific tasks, namely medical images, cells, histological data and related.\n\n## Models\n\nThe models here presented are just two, namely the [U-Net](https://arxiv.org/pdf/1505.04597.pdf)\nand the [MultiResUNet](https://arxiv.org/pdf/1902.04049.pdf). These models have been a very good\napplication of Fully Convolutional Networks to the medical image segmentation task, and are very\nwell suited for it.\n\n## Implementation\n\nEverything is implemented with [TensorFlow 2.0](tensorflow.org), using the newly acquired Keras API\nwithin TensorFlow. This allows for the flexibility and completeness of using the full TensorFlow\nlibrary while still having very good scripting capabilities with Keras.\n\n## Dependencies\n\nThere are several ways to install this package.\n\n### Using `pip`\n\nThe easiest way to install this package is using `pip` with the following command\n\n    pip install segmed\n\nalthough it is _highly encouraged_ to do this inside a virtual environment.\n\nIf using [Colaboratory](https://colab.research.google.com/notebooks/welcome.ipynb)\nthen this is the **preferred** way to use the package.\n\n**IMPORTANT**: When using Colaboratory one must always install `TensorFlow 2.0` first and then install `segmed`,\ni.e. this package, using the following commands in a cell within a Colaboratory notebook:\n```\n!pip install --upgrade pip\n!pip install segmed\n!pip install --upgrade tensorflow\n```\n\n### Using `poetry`\n\n[`poetry`](https://poetry.eustace.io/) is supported, by following the\n[installation](https://poetry.eustace.io/docs/#installation) instructions to get `poetry` installed, the following\ncommand should install `segmed` in a virtual environment:\n```shell\n# clone the repository\ngit clone https://github.com/DCI-NET/segmed\n# run poetry and install\npoetry install\n```\n\n`poetry` is a next-gen dependecy manager and makes everything a lot easier.\n\n### Using `conda`\n\nThis package also comes with a\n[conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)\nfor those that use the [Anaconda distribution](https://www.anaconda.com/distribution/).\n\nTo install the environment make sure you have [conda](https://conda.io/en/latest/) installed, then run the following\n\n    conda env create -f segmed_env.yml\n\nthis should ask you to confirm the installation, say yes and proceed with the installation. After that, activate the newly\ncreated environment\n\n    conda activate segmed\n\nand now you are ready to run the code within this repository.\n\n## Unit tests\n\nThis repository has some unit tests available that should be running constantly in the background,\nand the status of the current code build is displayed in the badge above (the one right to the title).\n\nOne can manually run the tests, too. You can download this repository with `git` like so:\n\n    git clone https://github.com/DCI-NET/segmed.git\n\nThen, you install [pytest](https://pytest.org/en/latest/) and just run the following command\n\n    pytest\n\nand the test suite should start running, with a few import and API warnings, but everything should pass\nif the badge above says _passing_ in green.\n\n## Examples\n\nThis repository also has some (_very_) barebones examples of how to use these models.\nHowever, they were run in a local machine and most of the data cannot be used.\nThese examples should be used as a _tutorial_ for the package,\njust to have a basic idea of how to run and create an image segmentation pipeline with `segmed`, \nbut you will _not_ be able to rerun the notebooks.\n\nThe reason for this is that most of the datasets are **very** large, so they cannot be bundled\nwith this repository; some other datasets **cannot** be redistributed as per request of the original authors.\n\nEither way, **all** of the trained models and weights are **freely available** upon request.\n\n### Demo\n\nFor completeness, here is a simple example. Assuming you have followed the instructions and everything is installed\ncorrectly, you can do the following to train a simple U-Net model:\n```python\nfrom segmed.train import train_unet\nfrom segmed.models import Unet\n\n# Define some example hyperparameters\nbatch_size = 8\nepochs = 50\nsteps_per_epoch=100\n\n# Declare the paths to use (following the Keras convention)\n# https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/keras/Model#fit_generator\ndata_path = "general/path/to/images"\nimg_path = data_path + "augmented/images/path"\nmasks_path = data_path + "augmented/masks/path"\nmodel_file = "path/to/save/model/unet_model.h5"\n\n# Create a Unet (custom) model with a regularizer and\n# batch normalization\ncustom_params = {\n    "activation": "relu",\n    "padding": "same",\n    "batch_norm": True,\n    "l2_reg": 0.995\n}\nmodel = Unet(variant="custom", parameters=custom_params)\n# Train the model!\nhistory = train_unet(\n    model,\n    img_path,\n    masks_path,\n    batch_size=batch_size,\n    epochs=epochs,\n    steps_per_epoch=steps_per_epoch,\n    model_file=model_file,\n)\n```\nNow, the training should have started and you\'re good to go!\n\n## Datasets\n\nThe datasets employed in some of the parts of this repository are the following:\n\n- [ISBI 2012 Challenge](http://brainiac2.mit.edu/isbi_challenge/home)\n- [Motion-based Segmentation and Recognition Dataset](http://mi.eng.cam.ac.uk/research/projects/VideoRec/CamVid/)\n- [DRIVE: Digital Retinal Images for Vessel Extraction](https://www.isi.uu.nl/Research/Databases/DRIVE/)\n- [Fast and Robust Segmentation of White Blood Cell Images by Self-supervised Learning](https://github.com/zxaoyou/segmentation_WBC)',
    'author': 'Edwin Bedolla',
    'author_email': 'developeredwin@gmail.com',
    'url': 'https://github.com/DCI-NET/segmed',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
