{"id":18029305,"url":"https://github.com/gmontamat/python-darknet-docker","last_synced_at":"2025-03-27T03:31:04.663Z","repository":{"id":88929613,"uuid":"352830905","full_name":"gmontamat/python-darknet-docker","owner":"gmontamat","description":"Docker images for Python with Darknet (https://github.com/AlexeyAB/darknet)","archived":false,"fork":false,"pushed_at":"2021-08-01T22:30:28.000Z","size":184,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T00:31:55.383Z","etag":null,"topics":["computer-vision","darknet","darknet-docker","darknet-python","darknet-yolo","deep-learning","docker","gpu-images","object-detection","python","video-inference","yolo","yolov4"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/gmontamat/python-darknet","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmontamat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-30T01:13:55.000Z","updated_at":"2022-09-26T19:48:12.000Z","dependencies_parsed_at":"2023-03-13T18:17:36.616Z","dependency_job_id":null,"html_url":"https://github.com/gmontamat/python-darknet-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpython-darknet-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpython-darknet-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpython-darknet-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpython-darknet-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmontamat","download_url":"https://codeload.github.com/gmontamat/python-darknet-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245778433,"owners_count":20670682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","darknet","darknet-docker","darknet-python","darknet-yolo","deep-learning","docker","gpu-images","object-detection","python","video-inference","yolo","yolov4"],"created_at":"2024-10-30T09:08:45.515Z","updated_at":"2025-03-27T03:31:04.645Z","avatar_url":"https://github.com/gmontamat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Darknet \u0026 Python Docker Images\n\n[![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/gmontamat/python-darknet)](https://hub.docker.com/r/gmontamat/python-darknet)\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/gmontamat/python-darknet-docker/Build%20and%20push%20tag%20to%20DockerHub)](https://github.com/gmontamat/python-darknet-docker/actions/workflows/build-push-tag.yaml)\n[![Docker Pulls](https://img.shields.io/docker/pulls/gmontamat/python-darknet)](https://hub.docker.com/r/gmontamat/python-darknet)\n[![GitHub](https://img.shields.io/github/license/gmontamat/python-darknet-docker)](https://github.com/gmontamat/python-darknet-docker/blob/main/LICENSE)\n\nPython Docker image with the [Darknet](https://github.com/AlexeyAB/darknet) package included. These images eliminate the\nburden of compiling Darknet's library (`libdarknet.so`) and import it into Python using\n[its wrapper](https://github.com/AlexeyAB/darknet/blob/master/darknet.py) to create YOLOv4, v3, v2 sample apps. Based\non [daisukekobayashi's darknet-docker images](https://github.com/daisukekobayashi/darknet-docker).\n\n## Base Image Tags\n\nCPU images are based on [Ubuntu Docker Official Images](https://hub.docker.com/_/ubuntu) (`ubuntu:20.04`) and GPU images\nare based on [nvidia/cuda](https://hub.docker.com/r/nvidia/cuda/) (`nvidia/cuda:11.2.2-cudnn8-runtime-ubuntu20.04`).\nImages include `python3.8`, an updated version of `pip`, and the following libraries:\n\n* [Darknet](https://github.com/AlexeyAB/darknet)\n* [Numpy](https://pypi.org/project/numpy/)\n* [OpenCV](https://pypi.org/project/opencv-python/)\n\nTags indicate whether the image supports GPU or not and which base image to use. They also refer to different flags in\nthe [`Makefile`](https://github.com/AlexeyAB/darknet/blob/master/Makefile) for building the library. You can check the\nmeaning of each\nflag [here](https://github.com/AlexeyAB/darknet#how-to-compile-on-linux-using-make \"How to compile on Linux\").\n\n* ``cpu`` tag indicates images are built with `AVX=1` and `OPENMP=1`\n    - The ``noopt`` tag means the AVX option is disabled (``AVX=0``). If you use a ``cpu`` image and get errors, try\n      this tag.\n* ``cv`` tag means the library is built with the `OPENCV=1` flag\n* ``gpu`` tag means images are built with ``GPU=1`` and ``CUDNN=1``\n    - The ``cc**`` tag indicates compute compatibility of GPU. Images with this tag are optimized for a certain GPU\n      architecture. You can check compute compatibility of your\n      GPU [here](https://developer.nvidia.com/cuda-gpus \"CUDA GPUs\"). If compute compatibility is greater than or equal\n      to 7.0, images are built with ``CUDNN_HALF=1``.\n* ``u1804`` tag means the images are based on `ubuntu:18.04` (when CPU-based) or\n  `nvidia/cuda:10.1-cudnn7-runtime-ubuntu18.04` (when GPU-based), and include `python3.6` instead of `python3.8`. Note\n  that `cc80` and `cc86` tags are not compatible with `ubuntu:18.04` base images.\n\n## Usage\n\n### Basic\n\nThe `python` interpreter runs by default when you start the container:\n\n```\n$ docker run -it --rm gmontamat/python-darknet:cpu\nPython 3.8.10 (default, Jun  2 2021, 10:49:15)\n[GCC 9.4.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e import darknet\n\u003e\u003e\u003e import numpy as np\n\u003e\u003e\u003e import cv2\n\u003e\u003e\u003e \n```\n\n### Run custom code\n\nUse volumes to share Python code in `/usr/src/app`, define it as the working directory, and specify the command to be\nrun. The following example shows how to do this using the [code included](./test) which is taken from the\n[Darknet repository](https://github.com/AlexeyAB/darknet/blob/master/darknet_images.py \"darknet_images.py\"):\n\n```bash\n$ git clone https://github.com/gmontamat/python-darknet-docker.git\n$ cd python-darknet-docker\n$ wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights \\\n       -O test/yolov4.weights\n$ xhost +\n$ docker run --gpus all -it --rm -v $(realpath ./test):/usr/src/app \\\n             -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY \\\n             -w /usr/src/app gmontamat/python-darknet:gpu python3 darknet_images.py \\\n             --input sample.jpg --weights yolov4.weights \\\n             --config_file cfg/yolov4.cfg --data_file cfg/coco.data\n```\n\nCheck the [troubleshooting docker GUI apps section](#troubleshooting-docker-gui-apps) for more information about\nthe `xhost` command.\n\n### Video inference\n\nPython is not the most suitable language to handle video streams. Compared to other compiled languages like *C++* or\nSDKs such as [NVIDIA DeepStream](https://developer.nvidia.com/deepstream-sdk), video inference won't run as smoothly.\nHowever, it is possible to perform real-time tracking on Python using its `multiprocessing` module and a powerful GPU.\nYOLOv4 \u0026 SORT run at 15fps on a system with an *Intel Core i7* and a *GeForce GTX 1080*. Mobile GPUs such as the\n*Quadro M1000M* run YOLOv4 at 3fps but can run YOLOv4-Tiny at 60fps.\n\nYou can test video inference using the [sample code in this repo](./test) taken from\nthe [Darknet repository](https://github.com/AlexeyAB/darknet/blob/master/darknet_video.py \"darknet_video.py\"):\n\n```bash\n$ git clone https://github.com/gmontamat/python-darknet-docker.git\n$ cd python-darknet-docker\n$ wget https://github.com/intel-iot-devkit/sample-videos/raw/master/face-demographics-walking.mp4 \\\n       -O test/face-demographics-walking.mp4\n$ wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights \\\n       -O test/yolov4-tiny.weights\n$ xhost +\n$ docker run --gpus all -it --rm -v $(realpath ./test):/usr/src/app \\\n             -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY \\\n             -w /usr/src/app gmontamat/python-darknet:gpu python3 darknet_video.py \\\n             --input face-demographics-walking.mp4 --weights yolov4-tiny.weights \\\n             --config_file cfg/yolov4-tiny.cfg --data_file cfg/coco.data\n```\n\nOr, if you prefer using your webcam (`/dev/video0` on Linux):\n\n```bash\n$ git clone https://github.com/gmontamat/python-darknet-docker.git\n$ cd python-darknet-docker\n$ wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights \\\n       -O test/yolov4-tiny.weights\n$ xhost +\n$ docker run --gpus all -it --rm -v $(realpath ./test):/usr/src/app \\\n             -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY \\\n             --device=/dev/video0 -w /usr/src/app gmontamat/python-darknet:gpu \\\n             python3 darknet_video.py --weights yolov4-tiny.weights \\\n             --config_file cfg/yolov4-tiny.cfg --data_file cfg/coco.data\n```\n\n#### Troubleshooting docker GUI apps\n\nRunning `xhost +` grants any local user access to your X screen. That might be OK for a single-user machine, but usually\nnot for a multi-user system. To get things back to normal, with controlled access to the X screen, run `xhost -`.\n\nIf you skip this command, you may encounter an error message like the following:\n\n```\nNo protocol specified\nError: Can't open display X:X\n```\n\nIt can also be fixed by running `xhost local:root` before you start the container, if you use Docker with `sudo`. Or, if\nyou use the `docker` group to run containers without `sudo`, run `xhost local:docker`.\n\n### Advanced usage\n\nThese images can serve as base images for more complex Docker applications where additional packages and dependencies\nare required. In such case, begin the `Dockerfile` with:\n\n```dockerfile\nFROM gmontamat/python-darknet:gpu\n```\n\n## TODO\n\n- [x] Use GitHub Actions instead of DockerHub hooks\n- [ ] Support other python versions (3.7/3.9)\n- [x] Use different base images (ubuntu:18.04/ubuntu:20.04)\n- [ ] Compile OpenCV python library for CUDA support instead of just using pre-built binaries\n  from [opencv-python](https://pypi.org/project/opencv-python/)\n\nThese images are still a work in progress. Feel free to submit feature requests\nin [the issues page](https://github.com/gmontamat/python-darknet-docker/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmontamat%2Fpython-darknet-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmontamat%2Fpython-darknet-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmontamat%2Fpython-darknet-docker/lists"}