Skip to main content

Unpaired Image-to-Image Translation with PyTorch+fastai

Project description

Unpaired image-to-image translation

A fastai/PyTorch package for unpaired image-to-image translation currently with CycleGAN implementation.

This is a package for training and testing unpaired image-to-image translation models. It currently only includes the CycleGAN, DualGAN, and GANILLA models, but other models will be implemented in the future.

This package uses fastai to accelerate deep learning experimentation. Additionally, nbdev was used to develop the package and produce documentation based on a series of notebooks.

Install

To install, use pip:

pip install git+https://github.com/tmabraham/UPIT.git

The package uses torch 1.7.1, torchvision 0.8.2, and fastai 2.3.0 (and its dependencies). It also requires nbdev 1.1.13 if you would like to add features to the package. Finally, for creating a web app model interface, gradio 1.1.6 is used.

How to use

Training a CycleGAN model is easy with UPIT! Given the paths of the images from the two domains trainA_path and trainB_path, you can do the following:

#cuda
from upit.data.unpaired import *
from upit.models.cyclegan import *
from upit.train.cyclegan import *
dls = get_dls(trainA_path, trainB_path)
cycle_gan = CycleGAN(3,3,64)
learn = cycle_learner(dls, cycle_gan,opt_func=partial(Adam,mom=0.5,sqr_mom=0.999))
learn.fit_flat_lin(100,100,2e-4)

The GANILLA model is only a different generator model architecture (that's meant to strike a better balance between style and content), so the same cycle_learner class can be used.

#cuda
from upit.models.ganilla import *
ganilla = GANILLA(3,3,64)
learn = cycle_learner(dls, ganilla,opt_func=partial(Adam,mom=0.5,sqr_mom=0.999))
learn.fit_flat_lin(100,100,2e-4)

Finally, we provide separate functions/classes for DualGAN model and training:

#cuda
from upit.models.dualgan import *
from upit.train.dualgan import *
dual_gan = DualGAN(3,64,3)
learn = dual_learner(dls, dual_gan, opt_func=RMSProp)
learn.fit_flat_lin(100,100,2e-4)

Additionally, we provide metrics for quantitative evaluation of the models, as well as experiment tracking with Weights and Biases. Check the documentation for more information!

Citing UPIT

If you use UPIT in your research please use the following BibTeX entry:

@Misc{UPIT,
    author =       {Tanishq Mathew Abraham},
    title =        {UPIT - A fastai/PyTorch package for unpaired image-to-image translation.},
    howpublished = {Github},
    year =         {2021},
    url =          {https://github.com/tmabraham/UPIT}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upit-0.1.1.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

upit-0.1.1-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file upit-0.1.1.tar.gz.

File metadata

  • Download URL: upit-0.1.1.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.7

File hashes

Hashes for upit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6e44d3bff062f2fc4b1d8567d0e266d68bc3003b6714d3e38c9aed6c18e80826
MD5 b961ac565bac9367579ff577496f0992
BLAKE2b-256 dc13301158d1bb339e516f7ddc28132a0d8d9ee16dd7e64c9005227aef7c4d28

See more details on using hashes here.

File details

Details for the file upit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: upit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 37.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.7

File hashes

Hashes for upit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b754ec822e35afb967a8de0223ee9b366a9d364b3a57be5294a6ebcb35c55f19
MD5 5cd1fb6339c30674ca9d9b2327a3e7df
BLAKE2b-256 a5529a2b4ccfc6903642842ba1d5d9b591e24b0e0603054eca3fd4f8af361898

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page