Skip to main content

ColourGAN

Simple PyTorch based GAN for colouring black and white images.

Installation

The code is available as python package.
Run following command for installing colourgan with all it's dependencies.

pip install colourgan

Additionally for trying out streamlit interface, please install streamlit using following command

pip install streamlit

You can also install it from this repository.

git clone https://github.com/narenderkumarnain/ColourGAN.git
cd ColourGAN
python setup.py install

Usage

Inference

For trying our pretrained model, please download the Generator Weight File
Now use these lines of code for inference on sample image.

#imports
import cv2
from colourgan.model import ColourGAN
from colourgan.config import get_cfg

# preparing the config
cfg = get_cfg()
# adding path to generator weights
cfg.initial_weights_generator = 'checkpoint_ep99_gen.pt'

# loading the model
model = ColourGAN(cfg , inference=True)

# loading the image
img = cv2.imread('sample.png')

# running inference
res = model.inference(img)

# saving result image
cv2.imwrite('sample_res.png' , res)

Streamlit interface

For trying out the streamlit interface, create a file app.py with following code.

# import
from colourgan.streamlit import app

# path to weights file
path_to_generator_weights = 'checkpoint_ep99_gen.pt'

if __name__ == '__main__':
    app(path_to_generator_weights)

We expect you have already installed streamlit.
Use followind code to run the application

streamlit run app.py

Training

Use following Lines of code for training the model on Cifar10 dataset.

# imports
import torch
from colourgan.config import get_cfg
from colourgan.data import Cifar10Dataset
from colourgan.model import ColourGAN

# Downloading the data and creating the dataloaders
dataloaders = Cifar10Dataset('cifar10', batch_size = 8).get_dataloaders()

# config
cfg = get_cfg()

# creating the model
model = ColourGAN(cfg)

# train
model.train(dataloaders['train'],dataloaders['test'], epochs = 100)

Pretrained Weights

Generator
Discriminator

References

GAN_image_colorizing

Colorizing-with-GANs

Metadata

Release files for colourgan 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colourgan 1.0.3
File Size Uploaded Provenance
colourgan-1.0.3.tar.gz 10.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for colourgan 1.0.3
File Interpreter ABI Platform
colourgan-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 22.5 kB

Release files / colourgan-1.0.3.tar.gz

Download URL colourgan-1.0.3.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
87e2adc83c0becff0635bba393a2257e4868fa5f2e41487e4ead26b18df63138
BLAKE2b-256 checksum
How to use checksums
40dc45eda9f855eee08ae03379ed4b7a3718c86f592b439ecf8e93d19b139170
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / colourgan-1.0.3-py3-none-any.whl

Download URL colourgan-1.0.3-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ac07e671acd178f9fff1a0613187b04a934f8be71ee4918faa31a83d37e5993
BLAKE2b-256 checksum
How to use checksums
486c6c7358f7cdc42ee4112dafd5dac9b354ed3faf39abd99b48d381a1ceef41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Security for colourgan 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page