EasyLaMa (WIP)

This is a tool combining EasyOCR and LaMa to automatically detect text and replace it with an inpainted background.

Installation

For GPU support install PyTorch with CUDA or ROCm support manually.

pip install git+https://github.com/kanttouchthis/2EasyLaMa

Usage

For a list of supported languages see EasyOCR

    from EasyLaMa import TextRemover
    
    tr = TextRemover(languages=["en", "de"], device="cuda)
    result, mask = tr("example.png", mask_edge=4, radius=0) # Can take filepath, url, PIL Image object as input. Returns result, mask as PIL Image object
    result.save("result.png")
    mask.save("mask.png")
    usage: easylama [-h] [-e EDGE] [-r RADIUS] [-o OUTPUT] [-m MASK] [-d DEVICE] [-l LANGUAGES [LANGUAGES ...]] image
    
    positional arguments:
      image                 Image to process. Required
    
    optional arguments:
      -h, --help            show this help message and exit
      -e EDGE, --edge EDGE  Extra margin at the edges of detected boxes. Default: 1
      -r RADIUS, --radius RADIUS
                            Radius for rounded corners. 0 = no rounding. Default: 1
      -o OUTPUT, --output OUTPUT
                            Filename for storing result, Default: "result.jpg"
      -m MASK, --mask MASK  Filename for storing mask. Default: don't store mask
      -d DEVICE, --device DEVICE
                            Device to use (cuda, cuda:0, cpu...). Default: cuda
      -l LANGUAGES [LANGUAGES ...], --languages LANGUAGES [LANGUAGES ...]
                            Languages to detect. See https://www.jaided.ai/easyocr/ for supported languages and their
                            abbreviations. Default: en