Skip to content

Standard way of getting list of classes for a model - exporting to ONNX #11240

Answered by wereii
wereii asked this question in Q&A
Discussion options

You must be logged in to vote

I guess I've just found the labels model.names.

# requires onnx>=1.12.0
from ultralytics import YOLO
import json

model = YOLO("yolov8n.pt")
model.export(format="onnx")


with open("yolov8n.labels.json", "w") as labels_file:
    data = {"labels": model.names}
    json.dump(data, labels_file)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by wereii
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants