Skip to content

intelligenerator/unet

Repository files navigation

unet

Basic U-Net implementation in pytorch.

Open In Colab

Table of Contents

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

If you would just like to play around with the model without downloading anything to your machine, you can open this notebook in Google Colab (Note that a Google account is required to run the notebook): Open in Google Colab

Prerequisites

You will need python3 and pip3 installed on your machine. You can install it from the official website https://www.python.org/.

To install pytorch with CUDA support, conda is recommended. An installation guide is available in the conda docs: https://docs.conda.io/projects/conda/en/latest/user-guide/install/

To be able to view und run the example notebooks on your machine, jupyter is required. An installation guide can be found on their website: https://jupyter.org/install

Initial setup

A step by step series of examples that tell you how to get the project up and running.

Clone the git repository

git clone https://github.com/intelligenerator/unet.git
cd unet

Then create your conda virtual environment

conda create --name torch
conda activate torch

Next, installed the required packages. This may vary based on your system hardware and requirements. Read more about pytorch installation: https://pytorch.org/get-started/locally/

conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

To exit the virtual environment run

conda deactivate

Happy coding!

Running the example notebook

To run the provided example notebook on your machine, make sure you have jupyter installed.

First, create a jupyter kernel for your conda environment:

pip install --user ipykernel
python -m ipykernel install --user --name=torch

Then, open jupyter lab:

jupyter lab

Important: Make sure you use the kernel you created above. After opening the notebook, navigate to Kernel > Change Kernel... in the UI and select torch from the dropdown. See this blog post for more info: https://janakiev.com/blog/jupyter-virtual-envs/

Usage

Assuming, you have cloned this repo into the unet/ subfolder, you can import it from your project root:

import torch
from unet import UNet

net = UNet(in_channels=3, out_channels=1)
# your code ...

Docs

Check out the unet docs for usage information.

For a more hands-on approach, feel free to experiment with the unet example on Google Colab.

Building the docs

To build the docs yourself, create a python virtual environment:

python3 -m venv venv
source venv/bin/activate

Next, install sphinx, numpydoc and the sphinx-rtd-theme:

pip install -r requirements.txt

Then, build the docs:

cd docs/
make html

Contributing

Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Ulysse McConnell - umcconnell

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments