DEV Community

Cover image for Bringing Black and White Photo to Life with DDColor
0xkoji
0xkoji

Posted on

Bringing Black and White Photo to Life with DDColor

DDColor can provide vivid and natural colorization for historical black-and-white photos.

GitHub logo piddnad / DDColor

[ICCV 2023] Official implementation of "DDColor: Towards Photo-Realistic Image Colorization via Dual Decoders"

🎨 DDColor

Official PyTorch implementation of ICCV 2023 Paper "DDColor: Towards Photo-Realistic Image Colorization via Dual Decoders".

arXiv HuggingFace ModelScope demo Replicate visitors

Xiaoyang Kang, Tao Yang, Wenqi Ouyang, Peiran Ren, Lingzhi Li, Xuansong Xie

DAMO Academy, Alibaba Group

🪄 DDColor can provide vivid and natural colorization for historical black and white old photos.

🎲 It can even colorize/recolor landscapes from anime games, transforming your animated scenery into a realistic real-life style! (Image source: Genshin Impact)

🔥 News

  • [2024-01-18] Add Replicate demo and API! Thanks @Chenxi.

  • [2023-12-13] Release the DDColor-tiny pre-trained model!

  • [2023-09-07] Add the Model Zoo and release three pretrained models!

  • [2023-05-15] Code release for training and inference!

  • [2023-05-05] The online demo is available!

Online Demo

We provide ModelScope online demo: ModelScope demo

You can also try the Replicate demo here: Replicate

Feel free to try it out!

Methods

In short: DDColor uses multi-scale visual features to optimize learnable color tokens (i.e. color queries) and achieves…

In this post, I’ll introduce how to run DDColor on Google Colab free-tier, T4.

Step 1. Clone the repo & install dependencies

First, we need to install dependencies and this step will take some time.

!git clone https://github.com/piddnad/DDColor
!cd DDColor
!pip install -r requirements.txt
!python setup.py develop
!pip install "modelscope[cv]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
Enter fullscreen mode Exit fullscreen mode

Step 2. Adding Colors to Image

import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from google.colab.patches import cv2_imshow

img_colorization = pipeline(Tasks.image_colorization, model='damo/cv_ddcolor_image-colorization')
result = img_colorization('https://th.bing.com/th/id/R.bfff865861dc593b14fa030a9ac2aee5?rik=Of2Q7oLKe0r0fg&riu=http%3a%2f%2fstatic.guim.co.uk%2fsys-images%2fGuardian%2fPix%2fpictures%2f2013%2f2%2f18%2f1361186749737%2fblack-and-white-picture-o-005.jpg&ehk=zoDQaeRIcKRivy%2fXZH7lZa3ixweCv47WKzD8uJGwZgw%3d&risl=&pid=ImgRaw&r=0')
cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])
cv2_imshow(result[OutputKeys.OUTPUT_IMG])
Enter fullscreen mode Exit fullscreen mode

Top comments (0)