GithubHelp home page GithubHelp logo

nielsrogge / ddcolor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from piddnad/ddcolor

0.0 1.0 0.0 13.35 MB

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

License: Apache License 2.0

Shell 0.13% Python 99.87%

ddcolor's Introduction

๐ŸŽจ 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!

  • [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 state-of-the-art performance on automatic image colorization.

Installation

Requirements

  • Python >= 3.7
  • PyTorch >= 1.7

Install with conda (Recommend)

conda create -n ddcolor python=3.8
conda activate ddcolor
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirements.txt

python3 setup.py develop  # install basicsr

Quick Start

Inference with modelscope library

  1. Install modelscope:
pip install "modelscope[cv]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
  1. Run the following codes:
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

img_colorization = pipeline(Tasks.image_colorization, model='damo/cv_ddcolor_image-colorization')
result = img_colorization('https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/audrey_hepburn.jpg')
cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])

It will automatically download the DDColor models.

You can find the model file pytorch_model.pt in the local path ~/.cache/modelscope/hub/damo.

Inference from local script

  1. Download the pretrained model file by simply running:
from modelscope.hub.snapshot_download import snapshot_download

model_dir = snapshot_download('damo/cv_ddcolor_image-colorization', cache_dir='./modelscope')
print('model assets saved to %s'%model_dir)

then the weights will be modelscope/damo/cv_ddcolor_image-colorization/pytorch_model.pt.

Or, download the model from Hugging Face.

  1. Run
sh scripts/inference.sh

Gradio Demo

  1. Install the gradio and other required libraries
!pip install gradio gradio_imageslider timm -q
  1. Run the demo
python gradio_app.py

Model Zoo

We provide several different versions of pretrained models, please check out Model Zoo.

Train

  1. Dataset preparation: download ImageNet dataset, or prepare any custom dataset of your own. Use the following script to get the dataset list file:
python data_list/get_meta_file.py
  1. Download pretrained weights for ConvNeXt and InceptionV3 and put it into pretrain folder.

  2. Specify 'meta_info_file' and other options in options/train/train_ddcolor.yml.

  3. Run

sh scripts/train.sh

Citation

If our work is helpful for your research, please consider citing:

@inproceedings{kang2023ddcolor,
  title={DDColor: Towards Photo-Realistic Image Colorization via Dual Decoders},
  author={Kang, Xiaoyang and Yang, Tao and Ouyang, Wenqi and Ren, Peiran and Li, Lingzhi and Xie, Xuansong},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={328--338},
  year={2023}
}

Acknowledgments

We thank the authors of BasicSR for the awesome training pipeline.

Xintao Wang, Ke Yu, Kelvin C.K. Chan, Chao Dong and Chen Change Loy. BasicSR: Open Source Image and Video Restoration Toolbox. https://github.com/xinntao/BasicSR, 2020.

Some codes are adapted from ColorFormer, BigColor, ConvNeXt, Mask2Former, and DETR. Thanks for their excellent work!

ddcolor's People

Contributors

chenxwh avatar piddnad avatar yvrjsharma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.