GithubHelp home page GithubHelp logo

adriaanbd / kamtutecs-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 30 KB

A Dockerized API for OCR and NLP using Tesseract, OpenCV, and spaCy.

Dockerfile 17.65% Python 82.35%
fastapi docker ocr nlp spacy tesseract translate

kamtutecs-api's Introduction

Kamtutecs

Getting Started

Instructions

  1. Setup Backend
  2. Setup Frontend
  3. Go to localhost:3000
  4. Upload image with horizontal text in it
  5. Draw a bounding box around the desired text to extract it
  6. Submit
  7. Open Developer Tools (F12)
  8. Look at the Console to see the response

Backend

Docker

$ git clone https://github.com/adriaanbd/kamtutecs-api.git
$ cd kamtutecs-api
$ docker-compose build
$ docker-compose up

Without Docker

$ apt-get -y install tesseract-ocr tesseract-ocr-spa
$ apt-get -y install libtesseract-dev
$ apt-get -y install libleptonica-dev
$ git clone https://github.com/adriaanbd/kamtutecs-api.git
$ cd kamtutecs-api
$ pip install -r requirements.txt
$ uvicorn app.main:app

Frontend

$ git clone https://github.com/adriaanbd/kamtutecs.git
$ cd kamtutecs
$ npm install
$ npm start

kamtutecs-api's People

Contributors

adriaanbd avatar dependabot[bot] avatar v4ld3rr4m4 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

kamtutecs-api's Issues

Extracting text from bottom left corner gives OpenCV error

Error with Stakeholders image extracting text from bottom left corner:

image

File "./app/main.py", line 99, in preprocess_img
kamtutecs |     grey_img = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2GRAY)
kamtutecs | cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-a98tlsvg/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

Translate OCR Text Error

When a different tesseract configuration is applied that produces an invalid OCR Text or an invalid OCR Text is passed on to translate(ocr_text) it produces the following error:

web_1  |   File "./app/main.py", line 158, in textract
web_1  |     translation = translate(ocr_text)
web_1  |   File "./app/main.py", line 122, in translate
web_1  |     language = detect_lang(text)
web_1  |   File "./app/main.py", line 64, in detect_lang
web_1  |     possible_lang = translator.detect(img_str)
web_1  |   File "/usr/local/lib/python3.8/dist-packages/googletrans/client.py", line 255, in detect
web_1  |     data = self._translate(text, 'en', 'auto', kwargs)
web_1  |   File "/usr/local/lib/python3.8/dist-packages/googletrans/client.py", line 78, in _translate
web_1  |     token = self.token_acquirer.do(text)
web_1  |   File "/usr/local/lib/python3.8/dist-packages/googletrans/gtoken.py", line 194, in do
web_1  |     self._update()
web_1  |   File "/usr/local/lib/python3.8/dist-packages/googletrans/gtoken.py", line 62, in _update
web_1  |     code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
web_1  | AttributeError: 'NoneType' object has no attribute 'group'

We could unit test this function and perhap passing it None to see if that's the issue indeed (because I'm not sure it is). A try/catch block would fix this temporarily as well.

OCR Text not entirely clean

While the translated text is cleaned (most of the time), the extracted text is not.

Check out the text at the end of the sentence:

ocr_text: "Improve the local economy by ensuring local businesses win city contracts. \u000c"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.