Skip to content

MangaLineExtraction_PyTorch: Extract Structural Lines from Manga in Python

AINewss Editorial

MangaLineExtraction_PyTorch is the official PyTorch port of the 2017 paper Deep Extraction of Manga Structural Lines. This guide explains the folder-based command, where to get erika.pth, the Python and OpenCV requirements, how the port compares with the original Theano weights, and when grayscale line extraction works beyond manga.

View 2 references
0 views 0 likes

Allow the functional cookie to save your likes. Privacy details

A manga panel being converted into clean black structural lines on a white background, representing line extraction from drawings.

MangaLineExtraction_PyTorch is a small research repository with a specific job: pulling clean structural lines out of a drawn page. This guide is based on the repository README and the paper it implements, read on 2 December 2026.

What is MangaLineExtraction_PyTorch?

MangaLineExtraction_PyTorch is the official PyTorch port of the 2017 paper Deep Extraction of Manga Structural Lines. It separates hand-drawn structural lines from a 2D manga page or illustration, leaving a clean line drawing. The repository is MIT licensed and maintained by ljsabc on GitHub.

The underlying paper is by Chengze Li, Xueting Liu and Tien-Tsin Wong, published in ACM Transactions on Graphics in July 2017, volume 36, issue 4, pages 117:1 to 117:12.

How do you run MangaLineExtraction_PyTorch on a folder of images?

Put your images in a source folder and call the script with a source and output path. The repository ships pytorchTestCases and pytorchResults folders as a worked example. It is a command-line batch tool rather than an interactive editor, so expect to inspect the output files afterwards.

python model_torch.py ./pytorchTestCases/ ./pytorchResults/

The README writes the invocation as model_torch.py [source folder] [output folder], so if Python is not on your path, call it with the interpreter explicitly.

Where do you get the erika.pth model weights?

The weights are not stored in the repository itself. The README points to the GitHub releases page, an older Dropbox download, and a Hugging Face pipeline from p1atdev that handles inference for you. Using the Hugging Face route avoids manual file placement.

Route What you get
GitHub releases Manual erika.pth download
Dropbox link in README Legacy direct download
p1atdev Hugging Face pipeline Standardised inference, ported and quantised model

What do you need to install?

Requirements are modest: Python 3, PyTorch (the author tested version 1.9) and Python-opencv. A later commit added CPU support, so a GPU is not mandatory. A Colab notebook is included for people who prefer not to install anything locally at all.

How faithful is the PyTorch port to the original research?

The author says the PyTorch weights are exactly the same as the older Theano model, with conversion error below 1e-3 across the 0 to 255 image range. The functional PyTorch interface is newer than the original code and is intended to make fine-tuning easier.

That conversion note matters if you are comparing outputs: the port is not a re-trained model with different behaviour, but a translated checkpoint with a verified numerical bound.

Does it work beyond black-and-white manga?

Yes, with a condition: the source needs clear hand-drawn lines. The README reports good results on colour cartoons and other nijigen-style images, and suggests loading them as grayscale, which is the default. Photographs or painterly art without distinct strokes are outside the demonstrated scope.

The repository's visual comparison places the input, sketchKeras, Anime2Sketch and this model side by side. The author describes Anime2Sketch as considered state of the art, so that image is a useful sanity check before you invest in a pipeline.

Can you fine-tune or embed the model?

The functional PyTorch interface is designed for that. The author explicitly suggests fine-tuning the model and dropping it into another project as a sub-module, for example to apply on-the-fly line extraction as a structural constraint during training or inference in a larger pipeline.

That is the main reason to choose this repository over a hosted line-art filter: you get weights and code you can import, subject to the MIT licence.

What are the practical limits?

This is a research port, not a polished product. The author calls the training code messy and points to an issue thread for details, the web demo needs translation help, and releases are infrequent. Always check the licence on any artwork you process; the gallery includes copyrighted samples credited to their source.

Other honest constraints from the repository:

  • No published benchmark table beyond the visual comparison.
  • The original training code is explicitly discouraged for anyone curious about reproduction.
  • The web demo at moeka.me is described as Gradio-like and may change without notice.
  • The README was last updated in January 2025, while most code dates to 2021.

Quick answers to common questions

There is a Colab notebook and a Gradio-like web demo for trying it without setup, plus a Hugging Face pipeline for simple inference. The repo had about 200 stars and 18 forks when checked in December 2026, which signals a small but usable research tool rather than a maintained commercial package.

Is there a CPU-only path?

Yes. A September 2021 commit added CPU support to the model and requirements files. Expect slower batches than on a GPU, but the tool remains usable for small folders.

Does it remove screentones and shading?

It targets structural lines, not every mark on the page. The paper's title and the repository's wording both narrow the task to structural lines from 2D manga, cartoons and illustrations, so treat tone removal as a different problem.

Bottom line on MangaLineExtraction_PyTorch

If you need reproducible line extraction from drawn artwork and can work from a command line, this repository is a credible, well-documented port with a clear licence and a numerically verified weight conversion. If you need a maintained application with support, it is not that. Verify input quality first, because the demonstrated strength is on clear hand-drawn strokes.

References

  1. ljsabc/MangaLineExtraction_PyTorch — READMEgithub.com
  2. Deep Extraction of Manga Structural Lines — project pagewww.cse.cuhk.edu.hk