Failed to load model because protobuf parsing failed.
eexposito opened this issue · 2 comments
Hi there, just downloaded v1.4.0 of Yolov8 and getting the exception "[ErrorCode:InvalidProtobuf] Failed to load model because protobuf parsing failed." when trying to do classification. Using yolov8x-cls.pt model for .Net6 project. Any help is greatly appreciated.
public IClassificationResult ClassifyObjects(string filePath) { try { using var predictor = new YoloV8(_modelPath); return predictor.Classify(filePath); } catch (Exception ex) { return null; } }
This happens because you are trying to load a model in PyTorch
format (.pt
extension), you must first export it to ONNX
format, then load it.
Run the following python code to export the model to ONNX format:
from ultralytics import YOLO
model = YOLO("yolov8x-cls.pt")
model.export(format="onnx")
Gotcha! Thanks for pointing me in the right direction.