Comments (9)
@noinsung hi there! It looks like you're encountering the LinAlgError
which typically points to an issue with the Kalman filter in the tracking algorithm where it's unable to process the covariance matrix properly.
This may happen if there's an inadequate detection input coming into the tracker. Hence, it's crucial to ensure that the detections fed into the tracker are valid and sufficiently accurate. One way to potentially mitigate this error is to tune the confidence threshold for detections, ensuring less noisy and more stable inputs to the tracker.
Hereβs a quick way to adjust the confidence threshold in your code:
model = YOLO("yolov8n.pt", conf=0.4) # Increase confidence threshold to 0.4
Adjust the conf
value to a level that reduces the error but retains adequate detections for your use case.
If the issue persists despite adjusting the confidence levels or other parameters, it could be beneficial to look into the specific scenarios or frames causing these errors. This might involve diving deeper into the tracker code or even modifying the Kalman filter setup for better stability in your specific use case.
Let me know how it goes or if you need further assistance! π
from ultralytics.
An error occurs when editing model = YOLO("yolov8n.pt", conf=0.4).
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
tracks = model.track(im0, persist=True, show=False,
classes=classes_to_count)
im0 = counter.start_counting(im0, tracks)
video_writer.write(im0)
===================================================
tracks = model.track(im0, persist=True, show=False,
classes=classes_to_count,conf=0.4)
I would like to ask if adding conf=0.4 is the correct way to fix it.
When you modify the above and run the program, it can run, but the same bug still occurs.
from ultralytics.
Hello! It looks like you're on the right track with adjusting the confidence level using conf=0.4
to refine the tracking input. However, setting the conf
parameter should be applied when you initialize the model, not during the track
method call.
Here's how you should correctly set it up:
model = YOLO("yolov8n.pt", conf=0.4) # Set your confidence threshold when loading the model
After setting this, you can continue with the tracking as you are doing in your script. Adjusting it directly in track()
won't affect the configuration as itβs not an accepted parameter there.
If the issue persists after this correction, it might be beneficial to assess if the error is due to specific frames in your video or consider if other parameters might also need tweaking based on your specific use case.
Let us know how it goes or if there's anything else we can help you with! π
from ultralytics.
from ultralytics import YOLO
from ultralytics.solutions import object_counter
import cv2
model = YOLO("yolov8n.pt", conf=0.4)
cap = cv2.VideoCapture("C:/Users/user/ultralytics-main/4K μ£Όνμμ κ°μλ κ°λ¦μ GANGNEUNG CITY DRIVING DOWN TOWN KOREA ROAD ASMR 4K 60P.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
line_points = [(0, 720), (1280, 720), (1280, 0), (0, 0)] # line or region points
#[(40, 500), (1220, 500), (1080, 360), (100, 360)]
classes_to_count = [0, 2, 3, 5, 7] # person and car classes for count
Video writer
video_writer = cv2.VideoWriter("1212object_counting_output.avi",
cv2.VideoWriter_fourcc(*'mp4v'),
fps,
(w, h))
Init Object Counter
counter = object_counter.ObjectCounter()
counter.set_args(view_img=True,
reg_pts=line_points,
classes_names=model.names,
draw_tracks=True,
line_thickness=2,view_out_counts=False)
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or video processing has been successfully completed.")
break
tracks = model.track(im0, persist=True, show=False,
classes=classes_to_count,conf=0.2)
im0 = counter.start_counting(im0, tracks)
video_writer.write(im0)
cap.release()
video_writer.release()
cv2.destroyAllWindows()
==========================================================
(E:\Anaconda3_envs\yolov8) C:\Users\user\ultralytics-main\ultralytics>python classcounting.py
Traceback (most recent call last):
File "classcounting.py", line 5, in
model = YOLO("yolov8n.pt", conf=0.4)
TypeError: init() got an unexpected keyword argument 'conf'
When running the above code, the following error occurs.
from ultralytics.
Hello! It looks like you're experiencing an issue with the initialization of the YOLO model with a conf
parameter. The correct way to apply a confidence threshold is not during initialization, but when you're making predictions or tracking objects.
For your script that involves tracking, if you want to set the confidence threshold, you should pass it to the track
method like this:
tracks = model.track(im0, conf=0.4, persist=True, show=False, classes=classes_to_count)
Make sure the conf
parameter is within the track
method. The YOLO
constructor does not accept conf
directly during model creation.
Let me know if modifying this resolves the issue, or if there's anything else you need help with! π
from ultralytics.
Yolov8 runs for about 10 minutes, but the same error message still occurs.
from ultralytics.
Hello! It sounds like you're still encountering issues even after adjusting the confidence threshold. This might be due to specific frames or scenarios in your video that are causing instability in the tracking algorithm.
Could you try logging the frame number or timestamp when the error occurs? This might help identify if there's a specific part of the video causing the issue. Here's a quick way to modify your loop to include this:
frame_number = 0
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("End of video or error reading frame.")
break
try:
tracks = model.track(im0, persist=True, show=False, classes=classes_to_count)
im0 = counter.start_counting(im0, tracks)
video_writer.write(im0)
except Exception as e:
print(f"Error on frame {frame_number}: {str(e)}")
break
frame_number += 1
This modification will print the frame number where the error occurs, which can be very helpful for debugging. Let us know how it goes! π
from ultralytics.
.
.
.
0: 384x640 2 cars, 14.0ms
Speed: 2.0ms preprocess, 14.0ms inference, 1.0ms postprocess per image at shape (1, 3, 384, 640)
0: 384x640 2 cars, 11.5ms
Speed: 2.5ms preprocess, 11.5ms inference, 2.0ms postprocess per image at shape (1, 3, 384, 640)
Error on frame 25203: 2-th leading minor of the array is not positive definite
The following error occurred. However, it does not necessarily end at the 25203rd frame, and the section where it ends is random each time the program is run. Based on the length of the video, sometimes it ends around 12 minutes, and sometimes it ends around 14 minutes.
I can't figure out what debugging to do to resolve this error.
from ultralytics.
Hello! It looks like you're encountering a stability issue with the Kalman filter used in the tracking algorithm, which can be sensitive to the quality of input detections. This error typically arises when the covariance matrix isn't positive definite, often due to numerical instabilities or inadequate detection inputs.
Here are a couple of suggestions to help you troubleshoot and potentially resolve this issue:
-
Adjust the Confidence Threshold: Increase the confidence threshold to ensure that only high-confidence detections are fed into the tracker. This can sometimes help stabilize the tracking updates.
tracks = model.track(im0, conf=0.5, persist=True, show=False)
-
Log More Information: Modify your code to log more detailed information about the detections and the state of the tracker right before the crash. This might help identify if specific detections or scenarios are causing the issue.
try: tracks = model.track(im0, persist=True, show=False) # Log detection details here except Exception as e: print(f"Error on frame {frame_number}: {str(e)}") # Optionally log additional state information here break
-
Review Input Data: Check if there are any anomalies in the video frames around the time the error occurs. Corrupted or highly unusual video data might be contributing to the instability.
If these steps don't help, consider providing a minimal reproducible example and the specific configurations you're using, so the community or the development team can further assist you! π
from ultralytics.
Related Issues (20)
- NCNN model - passing config parameters HOT 3
- ONNX model can't draw bbox but it predict well HOT 2
- Passing the parameters to new class HOT 3
- Get mAP on precomputed results? HOT 5
- Questions about ddp code HOT 2
- Cannot Train on Google Colaboratory with Custom Dataset HOT 4
- Issue with Continued Training in YOLOv8 Classification HOT 1
- How to load data using the LMDB HOT 2
- How to adapt the v8 model to incorporate the ordinal regression using the CORAL/CORN implementation. HOT 2
- ultralytics version compatibility issue with yolov8n-cls model HOT 2
- Resume training pretrained yolov8 segmentation model. HOT 5
- Error TypeError: new(): invalid data type 'str' for custom trainer HOT 1
- Error TypeError: new(): invalid data type 'str' for custom trainer HOT 1
- Validation result
- How to achieve more mAP50 for disease detection HOT 2
- Can SAHI inference performs real time object detection? HOT 2
- yolov8 : Adding New data class to customized yolov8 model HOT 2
- cuda/IndexKernel.cu:92: index out of bounds TORCH_USE_CUDA_DSA HOT 2
- mask_overlap=False still gives overlapping masks HOT 1
- GPU_mem = 0 Using Apple M2 Chip HOT 6
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.