Home

Awesome

Anime-InPainting: An application Tool based on Edge-Connect

<p align="left"> <img src="https://img.shields.io/badge/version-0.2-brightgreen.svg?style=flat-square" alt="Version"> <img src="https://img.shields.io/badge/status-Release-gold.svg?style=flat-square" alt="Status"> <img src="https://img.shields.io/badge/platform-win | linux-lightgrey.svg?style=flat-square" alt="Platform"> <img src="https://img.shields.io/badge/PyTorch version-1.0-blue.svg?style=flat-square" alt="PyTorch"> <img src="https://img.shields.io/badge/License-CC BY·NC 4.0-green.svg?style=flat-square" alt="License"> </p>

English | 中文版介绍

<hr>

Important

2019.3.27 Update:
Our latest drawing method PI-REC is more powerful.
Take a look on it, and I'm sure it won't disappoint you.

<hr> <p align="center"> <img src="files/banner.png" width="720" height="240"> </p>

Tool show time 🏳️‍🌈

Outputs

<p align="center"> <img src="files/show1.jpg" width="720" height="400"> </p>

Tool operation

<p align="center"> <img src="files/cut2.gif" width="425" height="425"> <img src="files/cut3.gif" width="406" height="222"> </p>

Introduction:

This is an optimized application tool which has a frontend based on Opencv, whose backend used Edge-Connect. Make sure you have read their awesome work and license thoroughly. Compared with the original work, this project has such <span id="improve">improvements</span> :

You can do the amazing Anime inpainting conveniently here.

And detailed training manual is released. You may train your own dataset smoothly now.

<span id='pre'>Prerequisites</span>

<span id='ins'>Installation</span>

pip install -r requirements.txt

Run the Tool

I want to run the tool! Calm down and follow such step:

Info: The following weights files are trained on anime face dataset which performs not good on a large whole anime character.

  1. Download the well trained model weights file --> Google Drive | Baidu
  2. Unzip the .7z and put it under your root directory. So make sure your path now is: ./model/getchu/<xxxxx.pth>
  3. Complete the above Prerequisites and Installation
  4. (Optional) Check and edit the ./model/getchu/config.yml config file as you wish
  5. Run the cooool tool:

Default Tool:

python tool_patch.py --path model/getchu/

Tool with edge window:

python tool_patch.py --edge --path model/getchu/

Args help

python tool_patch.py -h

PS. You can run any well trained model, not only above one. You can download more model weights files from the original work Edge-Connect. Then you can run the Tool as above. Only one thing to be careful: The config.yml in this project has some additional options than the config from the Edge-Connect.

Tool operation

For detailed manual, refer to your terminal prints or the __doc__ in tool_patch.py.

Below is the simplified tool operation manual:

Keydescription
Mouse LeftTo draw out the defective area in window input and to draw the edge in window edge
Mouse RightTo erase edge in window edge
Key [To make the brush thickness smaller
Key ]To make the brush thickness larger
Key 0Todo
Key 1Todo
Key nTo patch the black part of image, just use input image
Key eTo patch the black part of image, use the input image and edit edge (only work under edge window opened)
Key rTo reset the setup
Key sTo save the output
Key qTo quit

Training manual

Click here --> Training manual by yourself

<span id="jump_zh">中文版介绍🇨🇳 </span>

<hr>

重要

2019.3.27 更新:
我们的最新模型 PI-REC 更强大.
如果你想用最新的AI绘画黑科技,而非仅仅是修补图像,请点击上面的链接👆

<hr>

简介

Tool效果看上面👆 | Bilibili视频教程:TO DO

这是图像修补方向最新研究成果Edge-Connect阿姆斯特朗氮气加速魔改(优化)版。 用Opencv写了个前端部分,后端是Edge-Connect,方便当作工具使用。 此工具可以用来自动图像修补,去马赛克……同样优化了模型训练的过程。具体优化内容请看英文版Improvements

更新:训练手册已经填坑完发布了!你可以照着指南训练自己数据集了~

基础环境

第三方库安装

pip install -r requirements.txt

运行Tool

教练!我有个大胆的想法🈲……别急,一步步来:

注意:以下模型是在动漫头像数据集上训练的,所以对动漫全身大图修补效果一般,想自己再训练的参考下面的训练指南

  1. 下训练好的模型文件 --> Google Drive | Baidu
  2. 解压 .7z 放到你的根目录下. 确保你的目录现在是这样: ./model/getchu/<xxxxx.pth>
  3. 完成上面的基础环境和第三方库安装步骤
  4. (可选) 检查并编辑 ./model/getchu/config.yml 配置文件
  5. 使用以下命令运行:

默认Tool:

python tool_patch.py --path model/getchu/

带Edge编辑窗口的Tool:

python tool_patch.py --edge --path model/getchu/

命令行参数帮助

python tool_patch.py -h

PS. 你也能用tool跑别的任何模型,在这里下载原作更多模型Edge-Connect. 文件组织方式参考上面,其余运行命令都一样。唯一注意的是这个项目的 config.yml 比原作的多了几个选项,报错了的话注意修改。

Tool操作指南

详细内容请翻看控制台的打印内容,或查看tool_patch.py里的__doc__
简略版tool使用指南:

按键说明
鼠标左键Input窗口:画出瑕疵区域的遮盖,Edge窗口:手动画边缘
鼠标右键Edge窗口:橡皮擦
按键 [笔刷变细 (控制台打印粗细大小)
按键 ]笔刷变粗
按键 0Todo
按键 1Todo
按键 n修补黑色涂抹区域,只使用一张输入图片
按键 e修补黑色涂抹区域,使用输入图片和边缘图片(仅当edge窗口启动时有效)
按键 r全部重置
按键 s保存输出图片
按键 q退出

训练指南

训练指南 --> 阅读

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 paper <a href="https://arxiv.org/abs/1901.00212">EdgeConnect: Generative Image Inpainting with Adversarial Edge Learning</a>:

@inproceedings{nazeri2019edgeconnect,
  title={EdgeConnect: Generative Image Inpainting with Adversarial Edge Learning},
  author={Nazeri, Kamyar and Ng, Eric and Joseph, Tony and Qureshi, Faisal and Ebrahimi, Mehran},
  journal={arXiv preprint},
  year={2019},
}