Giter VIP home page Giter VIP logo

Comments (4)

github-actions avatar github-actions commented on June 25, 2024

👋 Hello @KieuSonTung, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

from ultralytics.

glenn-jocher avatar glenn-jocher commented on June 25, 2024

Hello!

Thank you for reaching out and providing details about your issue. Let's address your concerns step-by-step.

Frame Reduction Issue

The reduction in the number of frames from 48,000 to 24,000 suggests that the inference process might be skipping frames. This can happen due to the vid_stride parameter, which controls the frame stride for video inputs. By default, vid_stride is set to 1, meaning every frame is processed. If this parameter is set to a higher value, it will skip frames accordingly.

Could you please check if vid_stride is set in your args dictionary? If not, you can explicitly set it to 1 to ensure every frame is processed:

args['vid_stride'] = 1
model = DetectionPredictor(cfg=args)
results = model(source=video_path, stream=True)

Reducing Video FPS

Yes, YOLO does support reducing the video's FPS during inference or training. You can achieve this by adjusting the vid_stride parameter. For example, setting vid_stride to 2 will process every second frame, effectively halving the FPS:

args['vid_stride'] = 2  # Process every second frame
model = DetectionPredictor(cfg=args)
results = model(source=video_path, stream=True)

Next Steps

  1. Check vid_stride: Ensure vid_stride is set to 1 if you want to process every frame.
  2. Update Packages: Make sure you are using the latest versions of torch and ultralytics. You can update them using:
    pip install --upgrade torch ultralytics

If the issue persists after these steps, please provide a minimum reproducible example of your code. This will help us investigate further. You can refer to our minimum reproducible example guide for more details.

Feel free to reach out if you have any more questions or need further assistance. We're here to help! 😊

from ultralytics.

KieuSonTung avatar KieuSonTung commented on June 25, 2024

Hi @glenn-jocher . Thank you so much for replying.

I tried to adjust vid_stride parameter but it didn't work.

I used this code to print out the number of frames and fps

video_path = '/data/test_video/T160-1_video.mp4'

cap = cv2.VideoCapture(video_path)
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
fps = cap.get(cv2.CAP_PROP_FPS)

print('FRAME_COUNT', frame_count)

and it returns 22833 frames

And i ran this code to count the number of frames in the result output:

args['vid_stride'] = 1
    
model = DetectionPredictor(cfg=args)
results = model(source=video_path, stream=True)

cnt = 0

for r in results:
    cnt += 1

print(cnt)

and it returns 11411 frames.

What should I do next? Thank you so much.

from ultralytics.

glenn-jocher avatar glenn-jocher commented on June 25, 2024

Hi @KieuSonTung,

Thank you for providing additional details and the code snippets. Let's work together to resolve this issue.

Steps to Investigate Further

  1. Verify Package Versions:
    Ensure you are using the latest versions of torch and ultralytics. You can update them using:

    pip install --upgrade torch ultralytics
  2. Check Video Properties:
    Let's verify the video properties directly using OpenCV to ensure there are no discrepancies:

    import cv2
    
    video_path = '/data/test_video/T160-1_video.mp4'
    cap = cv2.VideoCapture(video_path)
    frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    fps = cap.get(cv2.CAP_PROP_FPS)
    
    print('FRAME_COUNT:', frame_count)
    print('FPS:', fps)
  3. Minimum Reproducible Example:
    If the issue persists, please provide a minimum reproducible example. This will help us investigate the problem more effectively. You can refer to our minimum reproducible example guide for more details.

  4. Debugging the Frame Count:
    Let's add some debug prints to understand where the frames might be getting skipped:

    from ultralytics.models.yolo.detect import DetectionPredictor
    
    args = {
        'vid_stride': 1,
        'device': '0',  # Example device, adjust as needed
        'project': 'runs/detect',
        'name': 'exp'
    }
    
    model = DetectionPredictor(cfg=args)
    results = model(source=video_path, stream=True)
    
    cnt = 0
    
    for r in results:
        cnt += 1
        print(f"Processing frame {cnt}")
    
    print(f"Total frames processed: {cnt}")

Next Steps

  1. Update Packages: Ensure you are using the latest versions of torch and ultralytics.
  2. Verify Video Properties: Run the provided code to check the frame count and FPS.
  3. Provide a Minimum Reproducible Example: If the issue persists, share a minimal code example that reproduces the problem.

By following these steps, we can better understand the issue and work towards a solution. Feel free to reach out if you have any more questions or need further assistance. We're here to help! 😊

from ultralytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.