Skip to content

Commit 60c5cb2

Browse files
authored
Easyocr (#972)
http://b/182904500
1 parent b5bb7e9 commit 60c5cb2

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,18 @@ RUN pip install flashtext && \
421421
pip install flask && \
422422
# pycrypto is used by competitions team.
423423
pip install pycrypto && \
424+
pip install easyocr && \
425+
/tmp/clean-layer.sh
426+
427+
# Download base easyocr models.
428+
# https://github.com/JaidedAI/EasyOCR#usage
429+
RUN mkdir -p /root/.EasyOCR/model && \
430+
wget --no-verbose "https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/latin.zip" -O /root/.EasyOCR/model/latin.zip && \
431+
unzip /root/.EasyOCR/model/latin.zip -d /root/.EasyOCR/model/ && \
432+
rm /root/.EasyOCR/model/latin.zip && \
433+
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 && \
434+
unzip /root/.EasyOCR/model/craft_mlt_25k.zip -d /root/.EasyOCR/model/ && \
435+
rm /root/.EasyOCR/model/craft_mlt_25k.zip && \
424436
/tmp/clean-layer.sh
425437

426438
# Tesseract and some associated utility packages

tests/data/english.png

1.66 MB
Loading

tests/test_easyocr.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import unittest
2+
3+
import easyocr
4+
5+
class TestEasyOCR(unittest.TestCase):
6+
def test_readtext(self):
7+
# The model_storage_directory is only need in tests where we overwrite HOME=/tmp
8+
reader = easyocr.Reader(['en'], gpu=False, model_storage_directory='/root/.EasyOCR/model')
9+
result = reader.readtext('/input/tests/data/english.png', detail = 0)
10+
# ['Reduce your risk of coronavirus infection:', 'Clean hands with soap and water',
11+
# 'or alcohol based hand rub', 'Cover nose and mouth when coughing and',
12+
# 'sneezing with tissue or flexed elbow', 'Avoid close contact with anyone with',
13+
# 'cold or flu like symptoms', 'Thoroughly cook meat and eggs',
14+
# 'No unprotected contact with live wild', 'or farm animals', 'World Health', 'Organization']
15+
self.assertEqual(len(result), 12)

0 commit comments

Comments
 (0)