Easyocr在Docker上

发布于 2025-01-20 13:48:53 字数 160 浏览 0 评论 0原文

我创建了一个 Docker 映像,其中包含一个使用 EasyOCR 的 Flask 应用程序。当您在端口上运行 docker 应用程序并且脚本调用 EasyOCR 模块时,它会开始下载字符识别模型,这会导致容器崩溃并终止。有没有办法可以将模型复制到 docker 文件中,这样一旦我必须运行它就不必这样做?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

世态炎凉 2025-01-27 13:48:53

我遇到了同样的问题,并从 EasyOCR 找到了问题的解决方案: https://github .com/JaidedAI/EasyOCR/issues/706

基本上,您需要像这样自定义 Dockerfile:

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

这将从模型中心手动下载它们并将它们放入'~/.EasyOCR/model' 文件夹

要查看每个模型并选择您需要的模型,请访问此链接:

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/

一袭白衣梦中忆 2025-01-27 13:48:53

我尝试过下载和解压模型并将其保存在 docker 文件夹中并按以下方式使用它的方法,

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

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")

一身骄傲 2025-01-27 13:48:53

确保Docker具有足够的内存分配并主动监视内存使用情况。 EasyOROCR是内存密集型的,如果您的容器无法记忆,则可能导致崩溃。您可以根据自己的喜好调整Docker的内存设置,并使用Docker Stats等工具来关注资源消耗。

Ensure that Docker has sufficient memory allocated and actively monitor the memory usage. EasyOCR is memory-intensive, and if your container runs out of memory, it may lead to crashes. You can adjust Docker’s memory settings in your preferences and use tools like docker stats to keep an eye on resource consumption.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文