[Python] Extract classes from yolo model

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    let us suppose that there is given image : [​IMG]

    i want to extract classes from given image using yolo model, so that those classes i can use for some monitoring purpose, i have run following code :

    from ultralytics import YOLO
    import matplotlib.pyplot as plt

    model = YOLO("yolo11n.pt")
    results =model("cat_dog.jpg")
    for detection in results[0]:
    print(detection.probs)


    and returned result is :

    image 1/1 C:\Users\User\PycharmProjects\Artificial_Inteligence\cat_dog.jpg: 640x576 2 cats, 1 dog, 88.4ms
    Speed: 3.1ms preprocess, 88.4ms inference, 1.5ms postprocess per image at shape (1, 3, 640, 576)
    None
    None
    None


    2 cats and 1 dog is returned as part of full string, but how to extract is seperately? for if-else condition? thanks in advance

    Continue reading...

Compartilhe esta Página