model prediction returns "None" for 'Keypoints', 'probs' and 'masks' attributes in YOLOV8 #5970
Replies: 2 comments 2 replies
-
@anemicwolf hello! The To obtain keypoints, you would need a model that is specifically trained for pose estimation or keypoint detection. Similarly, for If you want to perform these tasks, make sure to use the appropriate model file that supports the desired output. For example, for segmentation, you would use a model file that ends with Please ensure that you are using the correct model for your task. If you are looking to perform detection, segmentation, and pose estimation simultaneously, you would need a model that is trained to handle all these tasks or use separate models for each task and combine the results accordingly. For more information on how to use different models for various tasks such as detection, segmentation, classification, and pose estimation, you can refer to the Ultralytics documentation. 📚😊 |
Beta Was this translation helpful? Give feedback.
-
Hello, I can't seem to figure out why after running the code, results would always generate 'None' type for the 'Keypoints', 'probs' and 'masks' attributes. I'm assuming that it means there is no pointers to the respective objects or the objects were never generated to begin with. Any help would be much appreciated.
Code
import cv2
from ultralytics import YOLO
model = YOLO('yolov8x.pt') # load an official detection model
cap = cv2.VideoCapture(0) # 0 represents the default webcam (you can change it if you have multiple cameras)
if not cap.isOpened():
raise Exception("Could not open video device")
ret, frame = cap.read()
cap.release()
cv2.imwrite('captured_image.jpg', frame)
results = model('captured_image.jpg', save=True, conf=0.5, classes=0)
print(results)
Console Output:
image 1/1 /home/anemicwolf/PycharmProjects/ImageCaptureWebcam/captured_image.jpg: 480x640 1 person, 1473.4ms
Speed: 1.3ms preprocess, 1473.4ms inference, 1.3ms postprocess per image at shape (1, 3, 480, 640)
Results saved to runs/detect/predict28
[ultralytics.engine.results.Results object with attributes:
boxes: ultralytics.engine.results.Boxes object
keypoints: None
masks: None
names: {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus', 6: 'train', 7: 'truck', 8: 'boat', 9: 'traffic light', 10: 'fire hydrant', 11: 'stop sign', 12: 'parking meter', 13: 'bench', 14: 'bird', 15: 'cat', 16: 'dog', 17: 'horse', 18: 'sheep', 19: 'cow', 20: 'elephant', 21: 'bear', 22: 'zebra', 23: 'giraffe', 24: 'backpack', 25: 'umbrella', 26: 'handbag', 27: 'tie', 28: 'suitcase', 29: 'frisbee', 30: 'skis', 31: 'snowboard', 32: 'sports ball', 33: 'kite', 34: 'baseball bat', 35: 'baseball glove', 36: 'skateboard', 37: 'surfboard', 38: 'tennis racket', 39: 'bottle', 40: 'wine glass', 41: 'cup', 42: 'fork', 43: 'knife', 44: 'spoon', 45: 'bowl', 46: 'banana', 47: 'apple', 48: 'sandwich', 49: 'orange', 50: 'broccoli', 51: 'carrot', 52: 'hot dog', 53: 'pizza', 54: 'donut', 55: 'cake', 56: 'chair', 57: 'couch', 58: 'potted plant', 59: 'bed', 60: 'dining table', 61: 'toilet', 62: 'tv', 63: 'laptop', 64: 'mouse', 65: 'remote', 66: 'keyboard', 67: 'cell phone', 68: 'microwave', 69: 'oven', 70: 'toaster', 71: 'sink', 72: 'refrigerator', 73: 'book', 74: 'clock', 75: 'vase', 76: 'scissors', 77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'}
orig_img: array([[[167, 140, 103],
[167, 141, 101],
[168, 139, 100],
...,
[153, 148, 147],
[154, 149, 146],
[156, 151, 148]],
orig_shape: (480, 640)
path: '/home/anemicwolf/PycharmProjects/ImageCaptureWebcam/captured_image.jpg'
probs: None
save_dir: 'runs/detect/predict28'
speed: {'preprocess': 1.262664794921875, 'inference': 1473.3686447143555, 'postprocess': 1.2753009796142578}]
Process finished with exit code 0
Beta Was this translation helpful? Give feedback.
All reactions