AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.59k stars 7.95k forks source link

Docker RTSP issue (broken frames, artefacts) #8515

Open klearchos-stav opened 2 years ago

klearchos-stav commented 2 years ago

When building a docker image of yolov4, I receive broken frames / artefacts when processing RTSP streams as shown in attached pic. Has anyone encountered this issue? The non-docker implementation is working fine without any artefacts.

Dockerfile: FROM datamachines/cudnn_tensorflow_opencv:11.4.2_2.6.2_4.5.4-20211220 RUN apt-get -y install ffmpeg libsm6 libxext6 libxrender1 COPY YOLOV4 / RUN make -j$(nproc)

OpenCV version: 4.5.3

image_2022_05_13T13_22_31_489Z

Kannan665 commented 2 years ago

Docker uses the host's GTK and x11 for rendering videos and images... Once you build the docker container, while running it, you have to add the flags related to x11 pass through and host display along with volumes... Tomorrow, I will share you my docker build files for darknet and the docker run commands which I use.... I have not tried RTSP's from within my docker container, but have used videos for detection without any issues....

klearchos-stav commented 2 years ago

@Kannan665 Thank you very much for your response! Please share your docker files and run commands to cross-check with mine.

Kannan665 commented 2 years ago

from my home directory (host)... /home/kannan/yolo/

my_docker_build_cmd using datamachines docker hub repository (https://hub.docker.com/r/datamachines/tensorflow_opencv) and using this particular docker build tag (datamachines/cudnn_tensorflow_opencv:11.4.2_2.7.0_3.4.16-20220103)

docker build --tag=yolo:latest . Once it is built, I run the docker container using the below command....

docker run --privileged \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v /home/kannan/yolo/:/var/lib/yolo/ \ -e DISPLAY=$DISPLAY \ -p 5000:5000 \ -p 8888:8888 \ -v /dev/video0:/dev/video0 \ --gpus=all \ -it \ --rm \ yolo:latest The base image of datmachines, installs Tensorflow, Cuda and OpenCV together and build could take around 6 to 8 minutes....The --tag=yolo:latest is the one I use to exclusively build the container for working on darknet/yolo....I do use the same base image to build separate containers for Tensorflow Object Detection API also

And I am giving below the Dockerfile.....

FROM datamachines/cudnn_tensorflow_opencv:11.4.2_2.7.0_3.4.16-20220103

ARG DEBIAN_FRONTEND=noninteractive

Install apt dependencies

RUN apt-get update && apt-get install -y \ git \ gpg-agent \ python3-cairocffi \ protobuf-compiler \ python3-pil \ python3-lxml \ python3-tk \ wget \ libsm6 \ libxext6 \ ffmpeg \ libfontconfig1 \ libxrender1 \ libgl1-mesa-glx

RUN useradd -ms /bin/bash darknet USER darknet WORKDIR /home/darknet

RUN cd /home/darknet/ \ && wget -q --no-check-certificate -c https://github.com/AlexeyAB/darknet/archive/refs/tags/yolov4.tar.gz -O - | tar --strip-components=1 -xz -C /home/darknet/ \ && cd /home/darknet/ \ && perl -i.bak -pe 's%^(GPU|CUDNN|OPENCV|OPENMP|LIBSO)=0%$1=1%g;s%(compute_61])%$1 -gencode arch=compute_75,code=[sm_75,compute_75] -gencode arch=compute_86,code=[sm_86,compute_86]%' Makefile \ && make

WORKDIR /home/darknet CMD /bin/bash