🚀 MangaLineExtraction-hf
这是与Hugging Face transformers
库兼容的 MangaLineExtraction_PyTorch 版本。它能实现图像到图像的转换,尤其适用于漫画线条提取。
🚀 快速开始
代码示例
你可以使用以下代码进行漫画线条提取:
from PIL import Image
import torch
from transformers import AutoModel, AutoImageProcessor
REPO_NAME = "p1atdev/MangaLineExtraction-hf"
model = AutoModel.from_pretrained(REPO_NAME, trust_remote_code=True)
processor = AutoImageProcessor.from_pretrained(REPO_NAME, trust_remote_code=True)
image = Image.open("./sample.jpg")
inputs = processor(image, return_tensors="pt")
with torch.no_grad():
outputs = model(inputs.pixel_values)
line_image = Image.fromarray(outputs.pixel_values[0].numpy().astype("uint8"), mode="L")
line_image.save("./line_image.png")
或者,你也可以使用 pipeline
方式:
from transformers import pipeline
pipe = pipeline("image-to-image", model="p1atdev/MangaLineExtraction-hf", trust_remote_code=True)
pipe("sample.jpg")
示例结果展示
sample.jpg |
生成的线条图像 |
 |
 |
📚 详细文档
模型详情
- 开发者:Chengze Li, Xueting Liu, Tien-Tsin Wong
- 转换者:Plat
- 许可证:MIT
模型来源
- 仓库:https://github.com/ljsabc/MangaLineExtraction_PyTorch
- 论文:https://ttwong12.github.io/papers/linelearn/linelearn.pdf
- 项目页面:https://www.cse.cuhk.edu.hk/~ttwong/papers/linelearn/linelearn.html
📄 许可证
本项目采用 MIT 许可证。
📚 引用
如果你使用了该模型,请按照以下格式引用:
@article{li-2017-deep,
author = {Chengze Li and Xueting Liu and Tien-Tsin Wong},
title = {Deep Extraction of Manga Structural Lines},
journal = {ACM Transactions on Graphics (SIGGRAPH 2017 issue)},
month = {July},
year = {2017},
volume = {36},
number = {4},
pages = {117:1--117:12},
}