Easyocr在Docker上
我创建了一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,并从 EasyOCR 找到了问题的解决方案: https://github .com/JaidedAI/EasyOCR/issues/706
基本上,您需要像这样自定义 Dockerfile:
这将从模型中心手动下载它们并将它们放入
'~/.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:
This will download them manually from the model hub and put them in the
'~/.EasyOCR/model'
folderTo see every model and choose what you need, follow to this link: https://www.jaided.ai/easyocr/modelhub/
我尝试过下载和解压模型并将其保存在 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")
确保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.