yolo val classify data=path/to/ImageNet device=0
yolo val classify data=path/to/ImageNet batch=1 device=0|cpu
Train YOLO11n-cls on the MNIST160 dataset for 100 epochs at image size 64. For a full list of available arguments see the Configuration page.
Beispiel
from ultralytics import YOLO
# Load a model
model = YOLO("yolo11n-cls.yaml") # build a new model from YAML
model = YOLO("yolo11n-cls.pt") # load a pretrained model (recommended for training)
model = YOLO("yolo11n-cls.yaml").load("yolo11n-cls.pt") # build from YAML and transfer weights
# Train the model
results = model.train(data="mnist160", epochs=100, imgsz=64)
# Build a new model from YAML and start training from scratch
yolo classify train data=mnist160 model=yolo11n-cls.yaml epochs=100 imgsz=64
# Start training from a pretrained *.pt model
yolo classify train data=mnist160 model=yolo11n-cls.pt epochs=100 imgsz=64
# Build a new model from YAML, transfer pretrained weights to it and start training
yolo classify train data=mnist160 model=yolo11n-cls.yaml pretrained=yolo11n-cls.pt epochs=100 imgsz=64
YOLO Das Format der Klassifizierungsdatensätze findest du im Detail im Datensatz-Leitfaden.
Validate trained YOLO11n-cls model accuracy on the MNIST160 dataset. No arguments are needed as the model
seine Ausbildung beibehält data
und Argumente als Modellattribute.
Beispiel
from ultralytics import YOLO
# Load a model
model = YOLO("yolo11n-cls.pt") # load an official model
model = YOLO("path/to/best.pt") # load a custom model
# Validate the model
metrics = model.val() # no arguments needed, dataset and settings remembered
metrics.top1 # top1 accuracy
metrics.top5 # top5 accuracy
Use a trained YOLO11n-cls model to run predictions on images.
Beispiel
Siehe voll predict
Modus Details in der Vorhersage Seite.
Export a YOLO11n-cls model to a different format like ONNX, CoreML, etc.
Beispiel
Available YOLO11-cls export formats are in the table below. You can export to any format using the format
Argument, d.h. format='onnx'
oder format='engine'
. Du kannst exportierte Modelle direkt vorhersagen oder validieren, d.h. yolo predict model=yolo11n-cls.onnx
. Nach Abschluss des Exports werden Anwendungsbeispiele für dein Modell angezeigt.
Format | format Argument | Modell | Metadaten | Argumente |
---|---|---|---|---|
PyTorch | - | yolo11n-cls.pt | ✅ | - |
TorchScript | torchscript | yolo11n-cls.torchscript | ✅ | imgsz , optimize , batch |
ONNX | onnx | yolo11n-cls.onnx | ✅ | imgsz , half , dynamic , simplify , opset , batch |
OpenVINO | openvino | yolo11n-cls_openvino_model/ | ✅ | imgsz , half , int8 , batch |
TensorRT | engine | yolo11n-cls.engine | ✅ | imgsz , half , dynamic , simplify , workspace , int8 , batch |
CoreML | coreml | yolo11n-cls.mlpackage | ✅ | imgsz , half , int8 , nms , batch |
TF SavedModel | saved_model | yolo11n-cls_saved_model/ | ✅ | imgsz , keras , int8 , batch |
TF GraphDef | pb | yolo11n-cls.pb | ❌ | imgsz , batch |
TF Lite | tflite | yolo11n-cls.tflite | ✅ | imgsz , half , int8 , batch |
TF Kante TPU | edgetpu | yolo11n-cls_edgetpu.tflite | ✅ | imgsz |
TF.js | tfjs | yolo11n-cls_web_model/ | ✅ | imgsz , half , int8 , batch |
PaddlePaddle | paddle | yolo11n-cls_paddle_model/ | ✅ | imgsz , batch |
NCNN | ncnn | yolo11n-cls_ncnn_model/ | ✅ | imgsz , half , batch |
Siehe voll export
Details in der exportieren Seite.
YOLO11 models, such as yolo11n-cls.pt
sind für eine effiziente Bildklassifizierung konzipiert. Sie ordnen einem ganzen Bild eine einzige Klassenbezeichnung und eine Vertrauensbewertung zu. Dies ist besonders nützlich für Anwendungen, bei denen es ausreicht, die spezifische Klasse eines Bildes zu kennen, anstatt die Position oder Form von Objekten im Bild zu identifizieren.
To train a YOLO11 model, you can use either Python or CLI commands. For example, to train a yolo11n-cls
Modell auf dem MNIST160-Datensatz für 100 Epochen bei einer Bildgröße von 64:
Beispiel
Weitere Konfigurationsoptionen findest du auf der Seite Konfiguration.
Pretrained YOLO11 classification models can be found in the Modelle Abschnitt. Modelle wie yolo11n-cls.pt
, yolo11s-cls.pt
, yolo11m-cls.pt
usw., werden auf der Grundlage der ImageNet Datensatz und kann leicht heruntergeladen und für verschiedene Bildklassifizierungsaufgaben verwendet werden.
You can export a trained YOLO11 model to various formats using Python or CLI commands. For instance, to export a model to ONNX format:
Beispiel
Ausführliche Informationen zu den Exportoptionen findest du auf der Seite Export.
Um die Genauigkeit eines trainierten Modells anhand eines Datensatzes wie MNIST160 zu überprüfen, kannst du die folgenden Befehle verwenden: Python oder CLI :
Beispiel
Weitere Informationen findest du im Abschnitt Validieren.