Coder Social home page Coder Social logo

ct2's Introduction

CT2: Colorization Transformer via Color Tokens (official)

Introduction

This is the author's official PyTorch CT2 implementation.

We present Colorization Transformer via Color Tokens (CT2) to colorize grayish images while dealing with incorrect semantic colors and undersaturation without any additional external priors.

Prerequisites

  • Python 3.6
  • PyTorch 1.10
  • NVIDIA GPU + CUDA cuDNN

Installation

Clone this repo:

git clone https://github.com/shuchenweng/CT2.git

Install PyTorch and dependencies

http://pytorch.org

Install other python requirements

pip install -r requirement.txt

Download the pretrained vit model and move it to segm/resources/vit_large_patch16_384.npz

https://storage.googleapis.com/vit_models/augreg/L_16-i21k-300ep-lr_0.001-aug_medium1-wd_0.1-do_0.1-sd_0.1--imagenet2012-steps_20k-lr_0.01-res_384.npz

Datasets

We use ImageNet as our dataset, which includes 1.3M training data and covers 1000 categories. We test on the first 5k images of the public validation set, which is consistent with the previous Colorization transformer. All the test images are center cropped and resized into 256 × 256 resolution.

1) Training

A training script example is below:

python -m torch.distributed.launch --nproc_per_node=8 -m segm.train --log-dir segm/vit-large --batch-size 48 --local_rank 0  --partial_finetune False --backbone vit_large_patch16_384 --color_position True --add_l1_loss True --l1_conv True --l1_weight 10 --amp

2) Testing

To test your training weights, you could excute the script below:

python -m torch.distributed.launch --nproc_per_node=1 -m segm.test --log-dir segm/vit-large --local_rank 0 --only_test True

We also publish the pretrained weights here. Download and decompress it with extraction code v4ay. After renaming the weight as checkpoint.pth, move it to segm/vit-large to enjoy the colorization! Here is the alternative link.

If the colorization results are weired, please carefully check whether the pretrained weight path is correctly set.

License

Licensed under a Creative Commons Attribution-NonCommercial 4.0 International.

Except where otherwise noted, this content is published under a CC BY-NC license, which means that you can copy, remix, transform and build upon the content as long as you do not use the material for commercial purposes and give appropriate credit and provide a link to the license.

Citation

If you use this code for your research, please cite our papers CT2: Colorization Transformer via Color Tokens

@InProceedings{CT2,
  author = {Weng, Shuchen and Sun, Jimeng and Li, Yu and Li, Si and Shi, Boxin},
  title = {CT2: Colorization Transformer via Color Tokens},
  booktitle = {{ECCV}},
  year = {2022}
}

ct2's People

Contributors

shuchenweng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ct2's Issues

Question about mask_prior.pickle

Firstly, thank you for your great work!

I am running test.py, but there is an option "--add_mask", which is "default=True".

Then I checked the dataset, it seems load an extra file named "mask_prior.pickle" in coco.py. I also found it in single_test.py.

I wonder what it does & can you provide this file?

4 luminance prior

thanks for your great work! I want to know how to generate L1-L4 luminance prior. Could you provide some code?

Inference image on its original demension

When I ran the testing scripts with the pretrained models, I find I can only use 256*256 input image (or resize/crop my input image to 256*256). May I ask is there any chance for me to test any size image on its original demension?

Could you provide mask_prior.pickle?

Hi @shuchenweng :
Could you please provide mask_prior.pickle?
Now i want to test my own images for colorization but the test.py and single_test.py can't run successfully due to the lack of some pre-trained weights.
It will be better if you can provide one easy to run Colab demo for testing colorization.

Alternative link to the pretained weights, please?

Your code looks very interesting and I'd like to test it locally. But I can't connect to the link to download the pretrained weights. Others who have tried to download the pretrained weights report that the link requires the user to download and install an unknown application, which raises security and privacy concerns. Could you please include the pretrained weights on your github page or put the weights on a more user-friendly, easily accessible public site?

How could I address the two issues when I run test.py

FileNotFoundError: [Errno 2] No such file or directory: 'E:/samsung/datasets/imagenetval/val5000/val_fullfilenames.pickle'
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 6067)

Welcome update to OpenMMLab 2.0

Welcome update to OpenMMLab 2.0

I am Vansin, the technical operator of OpenMMLab. In September of last year, we announced the release of OpenMMLab 2.0 at the World Artificial Intelligence Conference in Shanghai. We invite you to upgrade your algorithm library to OpenMMLab 2.0 using MMEngine, which can be used for both research and commercial purposes. If you have any questions, please feel free to join us on the OpenMMLab Discord at https://discord.gg/amFNsyUBvm or add me on WeChat (van-sin) and I will invite you to the OpenMMLab WeChat group.

Here are the OpenMMLab 2.0 repos branches:

OpenMMLab 1.0 branch OpenMMLab 2.0 branch
MMEngine 0.x
MMCV 1.x 2.x
MMDetection 0.x 、1.x、2.x 3.x
MMAction2 0.x 1.x
MMClassification 0.x 1.x
MMSegmentation 0.x 1.x
MMDetection3D 0.x 1.x
MMEditing 0.x 1.x
MMPose 0.x 1.x
MMDeploy 0.x 1.x
MMTracking 0.x 1.x
MMOCR 0.x 1.x
MMRazor 0.x 1.x
MMSelfSup 0.x 1.x
MMRotate 1.x 1.x
MMYOLO 0.x

Attention: please create a new virtual environment for OpenMMLab 2.0.

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.