Comments (4)
👋 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):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
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.
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
- Check
vid_stride
: Ensurevid_stride
is set to 1 if you want to process every frame. - Update Packages: Make sure you are using the latest versions of
torch
andultralytics
. 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.
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.
Hi @KieuSonTung,
Thank you for providing additional details and the code snippets. Let's work together to resolve this issue.
Steps to Investigate Further
-
Verify Package Versions:
Ensure you are using the latest versions oftorch
andultralytics
. You can update them using:pip install --upgrade torch ultralytics
-
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)
-
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. -
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
- Update Packages: Ensure you are using the latest versions of
torch
andultralytics
. - Verify Video Properties: Run the provided code to check the frame count and FPS.
- 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)
- confusion matrix single HOT 2
- How to add the bounding box values to the labels text files during prediction with a trained YOLO-V8 instance segmentation model? HOT 4
- Class imabalance dataloader HOT 1
- Replace confidence score for forward pass for. yolov8. Default is 0.25 HOT 5
- The Yolov8 model is wrong in predicting probability HOT 2
- Superfluous line in Model HOT 2
- Re train yolov8n.pt to detect more objects from a custom dataset? HOT 6
- image 1/1 D:\yolov8\ultralytics-main\ultralytics\assets\bus.jpg: 640x480 (no detections), 510.2ms Speed: 15.5ms preprocess, 510.2ms inference, 18.0ms postprocess per image at shape (1, 3, 640, 480) HOT 4
- How to Shut Down Wandb HOT 1
- Issues with using dataset which is not is square dimensions. HOT 4
- Whether to support anchor-base HOT 3
- How can i plot the loss and mAP diagram after training yolov8 ? HOT 2
- YOLOv10 NCNN export HOT 2
- segmentation HOT 1
- unexpected freezed layer HOT 4
- KeyError When Customization to YOLOv8 Model: HOT 4
- YOLOv10 export: Setting simplify=True raise exception HOT 7
- TensorFlow & tflite Export Not Working HOT 5
- Different result between v8.1.2 and v8.2 on same dataset HOT 4
- RT-DETR load other pretrained weights HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.