5 篇文章带有标签 “OpenCV”

基于 FastAPI 开发 Ultralytics Serving

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: FastAPI",
            "type": "python",
            "request": "launch",
            "module": "uvicorn",
            "args": [
                "app.main:app",
                "--reload"
            ],
            "jinja": true,
            "justMyCode": true
        }
    ]
}

docker build docker buildx build 如何构建多架构 Docker 镜像?

Dockerfile 实践

  • DEBIAN_FRONTEND
  • 加速
    • apt 源
    • pypi 源
  • 安装
    • gcc
    • pip
    • Python
    • OpenCV

构建镜像

docker build -t gouchicao/ubuntu:20.04-python3-opencv4 .
  • requirements.txt 优先把 requirements.txt 文件拷贝到镜像中,然后安装依赖库,最后把程序代码拷贝进镜像中,主要是代码变动的频率比库变动的频率高,这样避免了每次都要重新安装依赖的库,加快构建镜像的速度。

Dockerfile OpenCV4 Ubuntu20.04

  1. ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 5, in <module>
    from .cv2 import *
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory

apt install -y libglib2.0-dev

需要交互,不能自动化安装。 apt install libglib2.0-dev Setting up tzdata (2020f-0ubuntu0.20.04.1) ...