Skip to content

Latest commit

 

History

History
51 lines (41 loc) · 1.87 KB

README.md

File metadata and controls

51 lines (41 loc) · 1.87 KB

ImageTranslator

This is a image translator package for python. This package is used by this project

The text binarization comes from this repository and the algorithm comes from this paper.

# Don't make high frequency requests to translator! Enterprises provide free services, we should remain grateful, not cause trouble

Usage

#translator=ImageTranslator(img, ocr, translator, src_lang, dest_lang)
#img: OpenCV image, PIL image, URL
#ocr: 'tesseract' or 'easyOCR'
#translator:'google', 'bing' or 'deepl'
#src_lang and dest_lang: looking the file lang.py
translator=ImageTranslator('https://i.stack.imgur.com/vrkIj.png','tesseract','google','eng','fra')
#For only processing the image
translator.processing()
#For translate the image
translator.translate()
image_out=translator.img_out
#img_out is OpenCV image
#You can use method run_translator for translate string

Installation

python -m pip install torch==1.7.0+cpu torchvision==0.8.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
python -m pip install easyocr

If you want to develop use git clone instead of pip installation

python -m pip git+git://github.com/A2va/ImageTranslator

Install tesseract in ImageTranslator/tesseract-orc or for Linux with the package manager

Use get-components command to download additionnal components.

get-components --mode all

You can replace all mode by one them:

  • tesseract : Download tessdata_best. Store it in the tesseract path (linux) or install in the project/tesseract/tessdata` (windows)
  • easyocr: Download all easyocr models
  • pyppeteer: Download chromium for using pyppeteer

Tests

Run tests with this command: python -m unittest