theAIGuysCode / yolov4-deepsort

Object tracking implemented with YOLOv4, DeepSort, and TensorFlow.
GNU General Public License v3.0
1.32k stars 751 forks source link

Yolov4 - Deep Sort Project: Loop Fails after a while #33

Open arapellis-odysseas opened 3 years ago

arapellis-odysseas commented 3 years ago

Hello, I 'm new in ml and I really feel the need to thank you for your tutorial. I tried a set up really interesting. I downloaded the Larix Broadcaster in my android phone and I set up a server to upload my video in PrimCast. (free version) . Everything set, I ran the following command python object_tracker.py --weights ./checkpoints/yolov4-tiny-416 --model yolov4 --video rtmp://162.244.80.42:1935/arapellisodisseas/livestream --tiny. After a while, the code fails according to the following image showing the terminal. It's not a real issue. Your code is perfect for me. Any insights??

Thank you. Larix Parameters_1 Larix Parameters_2 terminal

fail

karan-1700 commented 3 years ago

@arapellis-odysseas The execution-flow will move to the else: print('Video has ended or failed, try a different video format!') block only if it doesn't get any frames to process, i.e., the value of variable return_value becomes False. This means that the video has come to an end. But, since you are using a camera, the issue may be in the version of Python Packages you are using. To ensure that, Uncomment Step 3: Install Dependencies in the COLAB notebook shared by @theAIGuysCode and install the Python Packages written in the requirements-gpu.txt (or requirements.txt if you are using CPU) as below: !pip install -r requirements-gpu.txt. This will install the exact versions of the Python Packages for which this code works perfectly.

VigneshKathirkamar commented 2 years ago

Hi, I have faced this problem earlier while extracting frames from video. This happens if the frame is corrupted and hence not returned in "vid.read()".

You can use a pass statement in else to overcome this


while True:
        if return_value:
            return_value, frame = vid.read()
            frame = cv2.cvtColor(frame, cv2.COLOR_BR2RGB)
            image = Image.fromarray(frame)
        else:
           print("Corrupted frame")
           pass