EasyOCR on docker

1.5k views Asked by At

I created a Docker image that has a flask app that uses EasyOCR. When you run the docker app on a port, and the script calls the EasyOCR module, it starts downloading the character recognition model, which crashes and terminates the container. Is there a way I can copy the model to the docker file already, so it doesn't have to do that once I have to run it?

2

There are 2 answers

0
Otávio Augusto On

I was with the same problem, and found the solution on the issues from EasyOCR: https://github.com/JaidedAI/EasyOCR/issues/706

Basically, you need to custom your Dockerfile like this:

RUN wget https://github.com/JaidedAI/EasyOCR/releases/download/v1.3/english_g2.zip
RUN wget https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/craft_mlt_25k.zip
RUN mkdir ~/.EasyOCR
RUN mkdir ~/.EasyOCR/model
RUN unzip english_g2.zip -d ~/.EasyOCR/model
RUN unzip craft_mlt_25k.zip -d ~/.EasyOCR/model

This will download them manually from the model hub and put them in the '~/.EasyOCR/model' folder

To see every model and choose what you need, follow to this link: https://www.jaided.ai/easyocr/modelhub/

0
Animesh Nayak On

I have tried the approch of downloading and unzipping the model and keep it inside a folder of docker and using it in the below way,

reader = easyocr.Reader(['en'],download_enabled=False ,model_storage_directory="model-folder-path")