Implementation for "Seamless Manga Inpainting with Semantics Awareness" (SIGGRAPH 2021 issue)

Overview

Seamless Manga Inpainting with Semantics Awareness

[SIGGRAPH 2021](To appear) | Project Website | BibTex

Introduction:

Manga inpainting fills up the disoccluded pixels due to the removal of dialogue balloons or ``sound effect'' text. This process is long needed by the industry for the language localization and the conversion to animated manga. It is mostly done manually, as existing methods (mostly for natural image inpainting) cannot produce satisfying results. We present the first manga inpainting method, a deep learning model, that generates high-quality results. Instead of direct inpainting, we propose to separate the complicated inpainting into two major phases, semantic inpainting and appearance synthesis. This separation eases both the feature understanding and hence the training of the learning model. A key idea is to disentangle the structural line and screentone, that helps the network to better distinguish the structural line and the screentone features for semantic interpretation. Detailed description of the system can be found in our [paper](To appear).

Example Results

Belows shows an example of our inpainted manga image. Our method automatically fills up the disoccluded regions with meaningful structural lines and seamless screentones. Example

Prerequisites

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

Installation

  • Clone this repo:
git clone https://github.com/msxie92/MangaInpainting.git
cd MangaInpainting
pip install -r requirements.txt

Datasets

1) Images

As most of our training manga images are under copyright. We recommend you to use restored Manga109 dataset. Please download datasets from official websites and then use Manga Restoration to restored the bitonal nature. Please use a larger resolution instead of the predicted one to tolerant the prediction error. Exprically, set scale>1.4.

2) Structural lines

Our model is trained on structural lines extracted by Li et al.. You can download their publically available testing code.

3) Masks

Our model is trained on both regular masks (randomly generated rectangle masks) and irregular masks (provided by Liu et al.). You can download publically available Irregular Mask Dataset from their website. Alternatively, you can download Quick Draw Irregular Mask Dataset by Karim Iskakov which is combination of 50 million strokes drawn by human hand.

Getting Started

Download the pre-trained models using the following links and copy them under ./checkpoints directory.

MangaInpainting

ScreenVAE

Testing

To test the model, create a config.yaml file similar to the example config file and copy it under your checkpoints directory.

In each case, you need to provide an input image (image with a mask) and a mask file. Please make sure that the mask file covers the entire mask region in the input image. To test the model:

python test.py --checkpoints [path to checkpoints] \
      --input [path to the output directory]\
      --mask [path to the output directory]\
      --line [path to the output directory]\
      --output [path to the output directory]

We provide some test examples under ./examples directory. Please download the pre-trained models and run:

python test.py --checkpoints ./checkpoints/mangainpaintor \
      --input examples/test/imgs/ \
      --mask examples/test/masks/ \
      --line examples/test/lines/ \
      --output examples/test/results/

This script will inpaint all images in ./examples/manga/imgs using their corresponding masks in ./examples/manga/mask directory and saves the results in ./checkpoints/results directory.

Model Configuration

The model configuration is stored in a config.yaml file under your checkpoints directory.

Citation

If any part of our paper and code is helpful to your work, please generously cite with:

@inproceedings{xie2021seamless,
	title    ={Seamless Manga Inpainting with Semantics Awareness},
	author   ={Minshan Xie and Menghan Xia and Xueting Liu and Chengze Li and Tien-Tsin Wong},
	journal  = {ACM Transactions on Graphics (SIGGRAPH 2021 issue)},
	month    = {August},
	year     = {2021},
	volume   = {40},
        number   = {4},
        pages    = {96:1--96:11}
}

Reference

Comments
  • Question about lines image

    Question about lines image

    Hi, I'm trying to add MangaInpainting in the inpainting tool Lama Cleaner. I noticed the image of the lines get from MangaLineExtraction_PyTorch is different from the image of the lines in this repo. Do you use a custom-trained lines extract model to get the result?

    |line image in this repo| result of MangaLineExtraction_PyTorch| |---------------------|-----| |shegreat_0020|shegreat_0020|

    opened by Sanster 8
  • How to get the final result

    How to get the final result

    Thank you for sharing your great work!

    I ran your code with your pretrained model and example images as following command.

    python test.py --checkpoints ./checkpoints/mangainpaintor \
          --input examples/test/imgs/ \
          --mask examples/test/masks/ \
          --line examples/test/lines/ \
          --output examples/test/results/
    

    I got the following outputs.

    /MangaInpainting/src/config.py:8: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
      self._dict = yaml.load(self._yaml)
    initialize network with normal
    initialize network with xavier
    loading the model from checkpoints/ScreenVAE/latest_net_enc.pth
    loading the model from checkpoints/ScreenVAE/latest_net_dec.pth
    Loading models...
    Loading SemanticInpaintingModel generator...
    Loading MangaInpaintingModel generator...
    
    start testing...
    
    0 shegreat_0020.png
    
    End test....
    

    A results directory has been created containing four directories: lines_decode, manga_merged, masks, and screen_decode. However, there is no final inpainting result in them. How can I get the final result?

    opened by naoki7090624 6
  • How to calculate the distance field map and confidence map

    How to calculate the distance field map and confidence map

    Great work!! I have two questions about semantic inpainting.

    According to your paper, the distance field map M_d and confidence map M_c are weighted according to the distance from the boundary. It seems computationally intensive to calculate the distance from the boundary of each pixel, is there an efficient way to do this? If it's possible, would you share the code for that part?

    opened by naoki7090624 5
  • CUDA out of memory

    CUDA out of memory

    I tested one image using a RTX2080Ti, but I couldn't get the result due to "CUDA out of memory".

    RuntimeError: CUDA out of memory. Tried to allocate 3.38 GiB (GPU 0; 10.76 GiB total capacity; 5.69 GiB already allocated; 2.85 GiB free; 1.31 GiB cached)
    

    Can you tell me which GPUs you used and how long did it take you to train?

    opened by naoki7090624 3
  • About definition of

    About definition of "manga"

    It seems that the "manga" refers to early mangas. As far as I know, at early time, printer is also primitive and cannot print "grey", so it seems that "screentones" is just a way to adapt manga pictures to the printer. By converting grey color areas to "screentones" with different "density", they can print the manga on primitive printers. The examples in this repo and the paper seems to be of this type.

    Now, manga pictures use screentones as well, but it seems that they use it as an effect to reduce comsumption of ink. I mean, the manga pictures are no longer "binaries" that use density to describe color.

    opened by TsXor 1
  • Training images

    Training images

    Thank you for sharing great work!

    How did you collect many screened images for training? According to your paper, you manually collected 20,000 screened manga of resolution 2,048×1,536. Where and how did you get those images?

    opened by naoki7090624 1
  • What does the ones means?

    What does the ones means?

    At the networks.py line 218,

    ones = torch.ones_like(mask)
    # conv branch
    xnow = torch.cat([xin, ones, mask], dim=1)
    

    Does mask contatins all info of ones? Why add this in the network input?

    opened by jerrywyn 0
  • Easier install

    Easier install

    Part of #2 This PR primarily focuses on providing a docker container that generally works, and makes the code as platform independent as possible with ROCm and CPU fallback. Because requirements.txt was not installable as is, libraries were also updated, and deprecated functions replaced.

    Particularly, those using VS Code and have Development Containers set up should be able to just open the folder and have a correctly running environment.

    Caveats

    1. PyTorch has no support for GPUs on Macs whatsoever.
    2. CPU inference jobs are sometimes Killed in Docker because of additional memory overhead that tends to exceed the capacity of a Mac.
    3. The output is distorted, maybe because of breaking changes in nn.Upsample and imresize()

    shegreat_0020

    opened by illeatmyhat 2
  • too hard to install

    too hard to install

    i've been trying so hard to install this with everything required to use it, i cant get it to work. Please make it easier to use or a pre-built package with everything needed. I'm sure the app is great but its simply not user friendly.

    opened by SLDDL 0
Owner
null
This solves the autonomous driving issue which is supported by deep learning technology. Given a video, it splits into images and predicts the angle of turning for each frame.

Self Driving Car An autonomous car (also known as a driverless car, self-driving car, and robotic car) is a vehicle that is capable of sensing its env

Sagor Saha 4 Sep 4, 2021
Nicely is a real-time Feedback and Intervention Program Depression is a prevalent issue across all age groups, socioeconomic classes, and cultural identities.

Nicely is a real-time Feedback and Intervention Program Depression is a prevalent issue across all age groups, socioeconomic classes, and cultural identities.

null 1 Jan 16, 2022
Official implementation of "StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation" (SIGGRAPH 2021)

StyleCariGAN in PyTorch Official implementation of StyleCariGAN:Caricature Generation via StyleGAN Feature Map Modulation in PyTorch Requirements PyTo

PeterZhouSZ 49 Oct 31, 2022
Official implementation of "StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation" (SIGGRAPH 2021)

StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation This repository contains the official PyTorch implementation of the following

Wonjong Jang 270 Dec 30, 2022
General Virtual Sketching Framework for Vector Line Art (SIGGRAPH 2021)

General Virtual Sketching Framework for Vector Line Art - SIGGRAPH 2021 Paper | Project Page Outline Dependencies Testing with Trained Weights Trainin

Haoran MO 118 Dec 27, 2022
Supplementary code for SIGGRAPH 2021 paper: Discovering Diverse Athletic Jumping Strategies

SIGGRAPH 2021: Discovering Diverse Athletic Jumping Strategies project page paper demo video Prerequisites Important Notes We suspect there are bugs i

null 54 Dec 6, 2022
Code for HodgeNet: Learning Spectral Geometry on Triangle Meshes, in SIGGRAPH 2021.

HodgeNet | Webpage | Paper | Video HodgeNet: Learning Spectral Geometry on Triangle Meshes Dmitriy Smirnov, Justin Solomon SIGGRAPH 2021 Set-up To ins

Dima Smirnov 61 Nov 27, 2022
Tracing Versus Freehand for Evaluating Computer-Generated Drawings (SIGGRAPH 2021)

Tracing Versus Freehand for Evaluating Computer-Generated Drawings (SIGGRAPH 2021) Zeyu Wang, Sherry Qiu, Nicole Feng, Holly Rushmeier, Leonard McMill

Zach Zeyu Wang 23 Dec 9, 2022
PyTorch implementations for our SIGGRAPH 2021 paper: Editable Free-viewpoint Video Using a Layered Neural Representation.

st-nerf We provide PyTorch implementations for our paper: Editable Free-viewpoint Video Using a Layered Neural Representation SIGGRAPH 2021 Jiakai Zha

Diplodocus 258 Jan 2, 2023
Code for the SIGGRAPH 2021 paper "Consistent Depth of Moving Objects in Video".

Consistent Depth of Moving Objects in Video This repository contains training code for the SIGGRAPH 2021 paper "Consistent Depth of Moving Objects in

Google 203 Jan 5, 2023
ManipNet: Neural Manipulation Synthesis with a Hand-Object Spatial Representation - SIGGRAPH 2021

ManipNet: Neural Manipulation Synthesis with a Hand-Object Spatial Representation - SIGGRAPH 2021 Dataset Code Demos Authors: He Zhang, Yuting Ye, Tak

HE ZHANG 194 Dec 6, 2022
[SIGGRAPH Asia 2021] DeepVecFont: Synthesizing High-quality Vector Fonts via Dual-modality Learning.

DeepVecFont This is the homepage for "DeepVecFont: Synthesizing High-quality Vector Fonts via Dual-modality Learning". Yizhi Wang and Zhouhui Lian. WI

Yizhi Wang 17 Dec 22, 2022
[SIGGRAPH Asia 2021] DeepVecFont: Synthesizing High-quality Vector Fonts via Dual-modality Learning.

DeepVecFont This is the homepage for "DeepVecFont: Synthesizing High-quality Vector Fonts via Dual-modality Learning". Yizhi Wang and Zhouhui Lian. WI

Yizhi Wang 5 Oct 22, 2021
The implemetation of Dynamic Nerual Garments proposed in Siggraph Asia 2021

DynamicNeuralGarments Introduction This repository contains the implemetation of Dynamic Nerual Garments proposed in Siggraph Asia 2021. ./GarmentMoti

null 42 Dec 27, 2022
Face Identity Disentanglement via Latent Space Mapping [SIGGRAPH ASIA 2020]

Face Identity Disentanglement via Latent Space Mapping Description Official Implementation of the paper Face Identity Disentanglement via Latent Space

null 150 Dec 7, 2022
A code repository associated with the paper A Benchmark for Rough Sketch Cleanup by Chuan Yan, David Vanderhaeghe, and Yotam Gingold from SIGGRAPH Asia 2020.

A Benchmark for Rough Sketch Cleanup This is the code repository associated with the paper A Benchmark for Rough Sketch Cleanup by Chuan Yan, David Va

null 33 Dec 18, 2022
TilinGNN: Learning to Tile with Self-Supervised Graph Neural Network (SIGGRAPH 2020)

TilinGNN: Learning to Tile with Self-Supervised Graph Neural Network (SIGGRAPH 2020) About The goal of our research problem is illustrated below: give

null 59 Dec 9, 2022
Code release for Local Light Field Fusion at SIGGRAPH 2019

Local Light Field Fusion Project | Video | Paper Tensorflow implementation for novel view synthesis from sparse input images. Local Light Field Fusion

null 1.1k Dec 27, 2022