Skip to content

Commit

Permalink
Easyocr (#972)
Browse files Browse the repository at this point in the history
http:https://b/182904500
  • Loading branch information
Philmod committed Mar 18, 2021
1 parent b5bb7e9 commit 60c5cb2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,18 @@ RUN pip install flashtext && \
pip install flask && \
# pycrypto is used by competitions team.
pip install pycrypto && \
pip install easyocr && \
/tmp/clean-layer.sh

# Download base easyocr models.
# https://github.com/JaidedAI/EasyOCR#usage
RUN mkdir -p /root/.EasyOCR/model && \
wget --no-verbose "https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/latin.zip" -O /root/.EasyOCR/model/latin.zip && \
unzip /root/.EasyOCR/model/latin.zip -d /root/.EasyOCR/model/ && \
rm /root/.EasyOCR/model/latin.zip && \
wget --no-verbose "https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/craft_mlt_25k.zip" -O /root/.EasyOCR/model/craft_mlt_25k.zip && \
unzip /root/.EasyOCR/model/craft_mlt_25k.zip -d /root/.EasyOCR/model/ && \
rm /root/.EasyOCR/model/craft_mlt_25k.zip && \
/tmp/clean-layer.sh

# Tesseract and some associated utility packages
Expand Down
Binary file added tests/data/english.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions tests/test_easyocr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import unittest

import easyocr

class TestEasyOCR(unittest.TestCase):
def test_readtext(self):
# The model_storage_directory is only need in tests where we overwrite HOME=/tmp
reader = easyocr.Reader(['en'], gpu=False, model_storage_directory='/root/.EasyOCR/model')
result = reader.readtext('/input/tests/data/english.png', detail = 0)
# ['Reduce your risk of coronavirus infection:', 'Clean hands with soap and water',
# 'or alcohol based hand rub', 'Cover nose and mouth when coughing and',
# 'sneezing with tissue or flexed elbow', 'Avoid close contact with anyone with',
# 'cold or flu like symptoms', 'Thoroughly cook meat and eggs',
# 'No unprotected contact with live wild', 'or farm animals', 'World Health', 'Organization']
self.assertEqual(len(result), 12)

0 comments on commit 60c5cb2

Please sign in to comment.