zh/modes/predict/ #7982
Replies: 29 comments 41 replies
-
|
I finished my training.when I detect my images,how can i chang the box color? |
Beta Was this translation helpful? Give feedback.
-
|
if iuse model.predict(stream=True),how to stop predict |
Beta Was this translation helpful? Give feedback.
-
|
hello,I want to make my predictions output format like this, }] |
Beta Was this translation helpful? Give feedback.
-
|
I trained a data label of my own, person-with-bag, how do I count all the number of that label in a video? code like this: model = YOLO("D:\ultralytics-main\person-with-bag-best.pt") |
Beta Was this translation helpful? Give feedback.
-
|
I try the code you give me ,but when I run the code ,there is a error , the information :Traceback (most recent call last):
File "D:\ultralytics-main\Task\PersonCount.py", line 55, in <module>
if det.cls == model.names.index('person'):
AttributeError: 'dict' object has no attribute 'index'
908637049
***@***.***
…------------------ 原始邮件 ------------------
发件人: "ultralytics/ultralytics" ***@***.***>;
发送时间: 2024年3月19日(星期二) 晚上6:05
***@***.***>;
***@***.******@***.***>;
主题: Re: [ultralytics/ultralytics] zh/modes/predict/ (Discussion #7982)
@nwpu-caikun hello! 😊 To count all instances of your custom label "person-with-bag" in a video, you need to filter your results by the specific class and sum them up over all frames. Here's how you can modify your code to achieve that:
import cv2 from ultralytics import YOLO # Load your custom trained model model = YOLO("D:\\ultralytics-main\\person-with-bag-best.pt") cap = cv2.VideoCapture("D:\\ultralytics-main\\Resource\\b1-0208-0809.mp4") # Initialize the counter label_count = 0 while cap.isOpened(): success, frame = cap.read() if not success: break # Run inference results = model(frame) annotated_frame = results[0].plot() # Filter detections by your custom label and count for det in results[0].boxes: if det.cls == model.names.index('person-with-bag'): label_count += 1 video_writer.write(annotated_frame) print(f"Total 'person-with-bag' count: {label_count}")
Please make sure to replace 'person-with-bag' with the exact name of your class in the model's names attribute. This code assumes that you have a video writer setup (video_writer.write(annotated_frame)) to output the processed video. Let me know if this helps or if you have any further questions! 🚀
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I used your official code when counting the number of person in a one-hour video. In the final result I got the in_count number 751 and out_count number 1334. But the maximum tag number of person in the video is 5547 , does the maximum tag number have anything to do with the total number of in_count plus the out_count number ? pic are blow :
the main code is here:
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= 0)
im0 = counter.start_counting(im0, tracks)
print("in_count:{}".format(counter.in_counts))
print("out_count:{}".format(counter.out_counts))
video_writer.write(im0)
908637049
***@***.***
…------------------ 原始邮件 ------------------
发件人: "ultralytics/ultralytics" ***@***.***>;
发送时间: 2024年3月19日(星期二) 晚上6:05
***@***.***>;
***@***.******@***.***>;
主题: Re: [ultralytics/ultralytics] zh/modes/predict/ (Discussion #7982)
@nwpu-caikun hello! 😊 To count all instances of your custom label "person-with-bag" in a video, you need to filter your results by the specific class and sum them up over all frames. Here's how you can modify your code to achieve that:
import cv2 from ultralytics import YOLO # Load your custom trained model model = YOLO("D:\\ultralytics-main\\person-with-bag-best.pt") cap = cv2.VideoCapture("D:\\ultralytics-main\\Resource\\b1-0208-0809.mp4") # Initialize the counter label_count = 0 while cap.isOpened(): success, frame = cap.read() if not success: break # Run inference results = model(frame) annotated_frame = results[0].plot() # Filter detections by your custom label and count for det in results[0].boxes: if det.cls == model.names.index('person-with-bag'): label_count += 1 video_writer.write(annotated_frame) print(f"Total 'person-with-bag' count: {label_count}")
Please make sure to replace 'person-with-bag' with the exact name of your class in the model's names attribute. This code assumes that you have a video writer setup (video_writer.write(annotated_frame)) to output the processed video. Let me know if this helps or if you have any further questions! 🚀
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
hello,when I predict a 2MB mp4 video,the model returns me a 50MB avi video, how can I get a smaller video and how can I specify the return type like .mp4? thx |
Beta Was this translation helpful? Give feedback.
-
|
I am using the model to finish a image classification task, how can i get the predictive result and put it in a list? |
Beta Was this translation helpful? Give feedback.
-
|
Can you give some demo code for deployment? For example, |
Beta Was this translation helpful? Give feedback.
-
|
how can i change the save_dir and the save_crop_dir? |
Beta Was this translation helpful? Give feedback.
-
|
How to add a segmentation head for lane detection based on the target detection model. |
Beta Was this translation helpful? Give feedback.
-
|
How to choose the information to save in txt |
Beta Was this translation helpful? Give feedback.
-
|
Hello,Where does predictor return the results? |
Beta Was this translation helpful? Give feedback.
-
|
Hello,How to customize the return result of the model? |
Beta Was this translation helpful? Give feedback.
-
|
How to display the normal video playback speed in real time when detecting video files in yolov8? |
Beta Was this translation helpful? Give feedback.
-
|
when i use the "stream=True",the code return an error "FutureWarning: You are using 进程已结束,退出代码为 0" what can i do to deal with this bug? |
Beta Was this translation helpful? Give feedback.
-
|
How to change different batch size when I predict video with yolov8? |
Beta Was this translation helpful? Give feedback.
-
|
你好,我在以安装最新版yolo和torch11.8使用时发现预测十分卡顿,实时延迟可能有3到5秒,代码如下: -- coding: utf-8 --import torch import cv2 cap = cv2.VideoCapture(1) while cap.isOpened(): 请问如何解决,谢谢 |
Beta Was this translation helpful? Give feedback.
-
|
can I save my predict result as .xml files? |
Beta Was this translation helpful? Give feedback.
-
|
我很好奇,为啥同时import opencv和YOLO时,cv2.imread就能读取网络路径和包含中文路径的图片,但是只加载opencv时就不行,谁能告诉我这是什么原理,真的很好奇 |
Beta Was this translation helpful? Give feedback.
-
|
Hello, I would like to ask, my task is instance segmentation. At present, I get the predicted result is the original image superimposed label image, but the result I want is just the RGB label image, no need to superimpose the original image. Where do I need to make changes to make the result a segmented label image? |
Beta Was this translation helpful? Give feedback.
-
|
hello, i encountered a problemduring the prediction process with YOLOv8n_improved model. |
Beta Was this translation helpful? Give feedback.
-
0: 640x640 1 Bottom, 1 Side, 11.3ms |
Beta Was this translation helpful? Give feedback.
-
|
你好,我想问一下为什么我在推理相同的图像时,设置不同的imgsz参数,会有不同的结果。在一张图像上,有大船、小船、人。imgsz设置的值有640(默认)、1280、1980。640只能检测到大船;1280会检测到大船和小船,并且大船的置信度更高;1980还能检测到人。我很疑惑,模型的输入尺寸不是在训练的时候就已经固定了吗,这是否意味着推理的图像预处理阶段,不管我如何调整imgsz参数,模型都会将输入图像采样到640。但是现在出现的不同的结果,是为什么呢?下面是我的代码: |
Beta Was this translation helpful? Give feedback.
-
|
Dear Author, |
Beta Was this translation helpful? Give feedback.
-
|
Dear Author, |
Beta Was this translation helpful? Give feedback.
-
|
Hello, help Train the modelresults = model.train(data="vvv.yaml", Classesnames: results = self.model.predict(image, |
Beta Was this translation helpful? Give feedback.
-
|
Hi there, If no boxes/masks detected by the model, what will be the output of model inference. (results = model(["image1.jpg", "image2.jpg"]) #) I want to deal with the edge case. |
Beta Was this translation helpful? Give feedback.
-
|
hello! I used the YOLO11-pose model to estimate the key points of people in the automotive production workshop. However, the model often identified vehicles, hoists and other equipment as humans and calculated the key points, resulting in a relatively high false alarm rate. My question is: How can we prevent the model from identifying other objects and reduce the false alarm rate? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
zh/modes/predict/
了解如何在各种任务中使用YOLOv8 预测模式。了解不同的推理源,如图像、视频和数据格式。
https://docs.ultralytics.com/zh/modes/predict/
Beta Was this translation helpful? Give feedback.
All reactions