{"id":13719297,"url":"https://github.com/ImagingLab/Colorizing-with-GANs","last_synced_at":"2025-05-07T11:31:29.452Z","repository":{"id":201545270,"uuid":"118858669","full_name":"ImagingLab/Colorizing-with-GANs","owner":"ImagingLab","description":"Grayscale Image Colorization with Generative Adversarial Networks. https://arxiv.org/abs/1803.05400","archived":false,"fork":false,"pushed_at":"2022-09-05T00:16:08.000Z","size":24629,"stargazers_count":264,"open_issues_count":12,"forks_count":94,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-14T08:35:52.815Z","etag":null,"topics":["colorization","convolutional-networks","deep-learning","gans","generative-adversarial-network"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ImagingLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-01-25T03:45:42.000Z","updated_at":"2024-11-12T20:19:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"e136e987-dcd1-44f2-9f07-979f9f06302b","html_url":"https://github.com/ImagingLab/Colorizing-with-GANs","commit_stats":null,"previous_names":["imaginglab/colorizing-with-gans"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImagingLab%2FColorizing-with-GANs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImagingLab%2FColorizing-with-GANs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImagingLab%2FColorizing-with-GANs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImagingLab%2FColorizing-with-GANs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ImagingLab","download_url":"https://codeload.github.com/ImagingLab/Colorizing-with-GANs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252868847,"owners_count":21816925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colorization","convolutional-networks","deep-learning","gans","generative-adversarial-network"],"created_at":"2024-08-03T01:00:45.907Z","updated_at":"2025-05-07T11:31:28.844Z","avatar_url":"https://github.com/ImagingLab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image Colorization with Generative Adversarial Networks \nIn this work, we generalize the colorization procedure using a conditional Deep Convolutional Generative Adversarial Network (DCGAN) as as suggested by [Pix2Pix](https://arxiv.org/abs/1611.07004). The network is trained on the datasets [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html) and [Places365](http://places2.csail.mit.edu). Some of the results from Places365 dataset are [shown here.](#places365-results)\n\n## Prerequisites\n- Linux\n- Tensorflow 1.7\n- NVIDIA GPU (12G or 24G memory) + CUDA cuDNN\n\n## Getting Started\n### Installation\n- Clone this repo:\n```bash\ngit clone https://github.com/ImagingLab/Colorizing-with-GANs.git\ncd Colorizing-with-GANs\n```\n- Install Tensorflow and dependencies from https://www.tensorflow.org/install/\n- Install python requirements:\n```bash\npip install -r requirements.txt\n```\n\n### Dataset\n- We use [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html) and [Places365](http://places2.csail.mit.edu) datasets. To train a model on the full dataset, download datasets from official websites.\nAfter downloading, put then under the `datasets` folder.\n\n### Training\n- To train the model, run `main.py` script\n```bash\npython main.py\n```\n- To train the model on places365 dataset with tuned hyperparameters:\n```\npython train.py \\\n  --seed 100 \\\n  --dataset places365 \\\n  --dataset-path ./dataset/places365 \\\n  --checkpoints-path ./checkpoints \\\n  --batch-size 16 \\\n  --epochs 10 \\\n  --lr 3e-4 \\\n  --label-smoothing 1\n  \n```\n\n- To train the model of cifar10 dataset with tuned hyperparameters:\n```\npython train.py \\\n  --seed 100 \\\n  --dataset cifar10 \\\n  --dataset-path ./dataset/cifar10 \\\n  --checkpoints-path ./checkpoints \\\n  --batch-size 128 \\\n  --epochs 200 \\\n  --lr 3e-4 \\\n  --lr-decay-steps 1e4 \\\n  --augment True\n  \n```\n\n### Test\n- Download the pre-trained weights [from here.](https://drive.google.com/open?id=1jTsAUAKrMiHO2gn7s-fFZ_zUSzgKoPyp) and copy them in the `checkpoints` folder.\n- To test the model on a custom image(s), run `test.py` script:\n```bash\npython test.py \\\n  --checkpoints-path ./checkpoints \\        # checkpoints path\n  --test-input ./checkpoints/test \\         # test image(s) path\n  --test-output ./checkpoints/output \\      # output image(s) path\n```\n\n### Visual Turing Test\n- Download the pre-trained weights [from here.](https://drive.google.com/open?id=1jTsAUAKrMiHO2gn7s-fFZ_zUSzgKoPyp) and copy them in the `checkpoints` folder.\n- To evaluate the model qualitatively using visual Turing test, run `test-turing.py`:\n```bash\npython test-turing.py\n```\n\n- To apply time-based visual Turing test run (2 seconds decision time):\n```bash\npython test-turing.py --test-delay 2\n```\n\n\n## Networks Architecture\nThe architecture of generator is inspired by  [U-Net](https://arxiv.org/abs/1505.04597):  The architecture of the model is symmetric, with `n` encoding units and `n` decoding units. The contracting path consists of 4x4 convolution layers with stride 2 for downsampling, each followed by batch normalization and Leaky-ReLU activation function with the slope of 0.2. The number of channels are doubled after each step. Each unit in the expansive path consists of a 4x4 transposed convolutional layer with stride 2 for upsampling, concatenation with the activation map of the mirroring layer in the contracting path, followed by batch normalization and ReLU activation function. The last layer of the network is a 1x1 convolution which is equivalent to cross-channel parametric pooling layer. We use `tanh` function for the last layer.\n\u003cp align='center'\u003e  \n  \u003cimg src='img/unet.png' width='700px' height='168px' /\u003e\n\u003c/p\u003e\n\nFor discriminator, we use patch-gan architecture with contractive path similar to the baselines: a series of 4x4 convolutional layers with stride 2 with the number of channels being doubled after each downsampling. All convolution layers are followed by batch normalization, leaky ReLU activation with slope 0.2. After the last layer, a sigmoid function is applied to return probability values of `70x70` patches of the input being real or fake. We take the average of the probabilities as the network output!\n  \n## Places365 Results\nColorization results with Places365. (a) Grayscale. (b) Original Image. (c) Colorized with GAN.\n\u003cp align='center'\u003e  \n  \u003cimg src='img/places365.jpg' /\u003e\n\u003c/p\u003e\n\n## Citation\nIf you use this code for your research, please cite our paper \u003ca href=\"https://arxiv.org/abs/1803.05400\"\u003eImage Colorization with Generative Adversarial Networks\u003c/a\u003e:\n\n```\n@inproceedings{nazeri2018image,\n  title={Image Colorization Using Generative Adversarial Networks},\n  author={Nazeri, Kamyar and Ng, Eric and Ebrahimi, Mehran},\n  booktitle={International Conference on Articulated Motion and Deformable Objects},\n  pages={85--94},\n  year={2018},\n  organization={Springer}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FImagingLab%2FColorizing-with-GANs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FImagingLab%2FColorizing-with-GANs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FImagingLab%2FColorizing-with-GANs/lists"}