🧹 Manga Text Cleaner / منظّف نصوص المانجا

Model weights + ready-to-run Gradio app that removes text (speech bubbles, sound effects, narration boxes) from manga / comic pages and rebuilds the background.

أوزان نموذج الكشف + تطبيق Gradio جاهز يزيل النصوص من صفحات المانجا والكوميك ويعيد بناء الخلفية.

Quick start / البداية السريعة

Option 1 — this Space

The app above runs on this Space. Upload a page, or a ZIP of pages, press ابدأ التنظيف and download the result.

التطبيق بالأعلى يعمل على هذا Space. ارفع صفحة أو ZIP، اضغط «ابدأ التنظيف»، ونزّل النتيجة.

Option 2 — Google Colab (free)

Open Manga_Cleaner_Colab.ipynb → Open in Colab → run the three cells → a public gradio.live link appears.

Cell 1 installs the packages, cell 2 downloads the models from this repo, cell 3 launches the app with a public share link you can send to your friends. The link stops working when you stop the cell.

افتح الدفتر من زر Open in Colab وشغّل الخلايا الثلاث. الرابط العام يعمل ما دامت الخلية شغالة.

Option 3 — on your own PC / على جهازك

git clone https://huggingface.co/kzome/manga-cleaner
cd manga-cleaner
pip install -r requirements.txt
python app.py

On Windows use setup.bat once and then run.bat.

Option 4 — share it with friends / مشاركة الرابط مع الأصدقاء

File Who can open it Needs
run.bat only you, on this PC nothing
share.bat anyone on the same Wi-Fi same network
share.bat public anyone, via a gradio.live tunnel nothing
tunnel.bat anyone, via a trycloudflare.com tunnel nothing

tunnel.bat is the reliable option for friends on other networks: it starts the app on loopback only and publishes it through a Cloudflare tunnel, so nothing is exposed on your LAN and no router or firewall change is needed. It prints a https://....trycloudflare.com link and opens it in your browser.

tunnel.bat

The link changes every time you run it, and stops when you close the tunnel window. Keep that window open while your friends work.

If friends get "refused to connect" on the LAN link, the request never reached the app. In order of likelihood:

  1. the share.bat window was closed — the server only runs while it is open;
  2. the friend is on a different network — they must be on the same LAN;
  3. the Windows Firewall is blocking the app's Python.

share.bat adds the firewall rule itself the first time it runs. To do it by hand, run this in PowerShell as Administrator:

.\allow-firewall.ps1

share.bat shuts down when you close it, so there is no way to reach the app afterwards — that is the difference between a refused connection and a timeout.

tunnel.bat is the better option for friends on other networks. It uses Cloudflare Tunnel, keeps the app on 127.0.0.1 and publishes it over HTTPS, so nothing is exposed on your LAN. Both share and tunnel stream the pages through the machine running the app, so only share them with people you trust.

tunnel.bat يشغّل التطبيق على 127.0.0.1 فقط وينشره عبر نفق Cloudflare، فيصير الرابط https://...trycloudflare.com يعمل من أي شبكة دون تعديل الراوتر أو الجدار الناري. الرابط يتغير كل مرة تشغيل وينتهي بإغلاق نافذة النفق.

share.bat يشغّل السيرفر على كل الواجهات ويطبع رابط http://<ip-جهازك>:7860. أرسله لأصدقائك وهم على نفس شبكة الواي-فاي. share.bat public يفتح رابط gradio.live لأي شخص على الإنترنت، لكنه ينتهي بمجرد إغلاق النافذة.

إذا ظهر لصديقك «refused to connect» فالطلب ما وصل للتطبيق، والسبب غالباً بترتيب: النافذة انغلقت، أو صديقك على شبكة ثانية، أو الجدار الناري. نفّذ allow-firewall.ps1 كمدير مرة واحدة لتفادي第三条.

How it works / كيف يعمل

  1. Detection — comic-text-detector (ONNX, executed through OpenCV DNN) produces a text mask for each page.
  2. Region merging — nearby text areas are merged so the inpainter sees one clean region.
  3. Filling — each region is either
    • filled with the median colour of its surrounding pixels when the background is flat (white bubbles, plain panels) — fast and lossless, or
    • inpainted with LaMa when the background is complex (artwork, gradients).
  4. Output — a ZIP of clean pages (PNG or JPG) plus a red-overlay preview showing exactly what was erased.

Files in this repo

File What it is
data/comictextdetector.pt.onnx text detection model (ONNX, ~90 MB)
data/big-lama.pt LaMa inpainting model, TorchScript (~196 MB)
app.py Gradio web app, Arabic + English
cleaner.py the cleaning pipeline (region merge → flat fill or LaMa)
lama.py minimal TorchScript loader for big-lama.pt
inference.py, basemodel.py, utils/, models/ detection code from comic-text-detector
Manga_Cleaner_Colab.ipynb ready-to-run Colab notebook

Settings explained

Setting What it does
Mask thickness Dilation of the detected text mask. Bigger = erases more (catches outlines and SFX).
Merge nearby regions Distance under which two text areas are inpainted as one block.
Context margin Extra pixels cropped around a region and given to LaMa as context.
Flat background threshold A region whose border colour deviation is below this value is filled with its median colour instead of running LaMa.

If text survives → raise Mask thickness. If faces get damaged → lower it or raise Flat background threshold. Turn on preview when unsure: it shows the detected areas in red.

Speed

Detection runs on OpenVINO instead of OpenCV DNN. Measured on a 2-core / 4-thread Intel i5-6300U, per 1200 px slice:

engine time / slice result
OpenCV DNN (1 thread, the old default) 21.0 s reference
OpenCV DNN (4 threads) 14.6 s identical
OpenVINO CPU 2.4 s bit-identical (mask IoU 1.00000)
OpenVINO GPU (Intel HD 520) 0.8 s IoU 0.99850, not identical

A real page (800x8734, 8 slices, 16 regions, 12 LaMa calls) went from 106 s to 35 s. On top of that torch is pinned to all CPU threads, which alone made LaMa ~1.8x faster.

Use the GPU checkbox only if you have an Intel GPU and accept the tiny numerical difference; on Colab, pick the T4 runtime so LaMa runs on CUDA. Long webtoon strips are still slow overall - split them into batches, and set CHUNK_H in cleaner.py to trade detection quality for speed.

Credits

License

The detection code is GPL-3.0 (see LICENSE, from comic-text-detector) and the detection model comes from manga-image-translator, which is AGPL-3.0 — so the combined work is best treated as AGPL-3.0, which is what this repo is declared under. LaMa (big-lama.pt) is Apache-2.0. If you redistribute this or offer it as a service, keep the license and the attribution above.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Spaces using kzome/manga-cleaner 3