is there pt format model file, thanks!!
#1
by
NemesisPrime
- opened
the "pytorch_model.bin" could not be loaded, do you have pt form of model file. Thanks a lot!!
same can't load the safetensors file too
same
docs are incomplete, missing critical information!
Revert to the earlier commit to find and download the best.pt
file.
from ultralytics import YOLO
from PIL import Image
model = YOLO('best.pt')
image = Image.open("path/to/image.jpg")
results = model.predict(image, conf=0.25, iou=0.45)
results[0].show()
The model loads and predicts fire and smoke objects. At a glance, it works.
p.s. - I also couldn't get the bin
and safetensors
model weight files working, even after renaming OrderedDicts keys, there were missing keys, as required by yolo.load_state_dict()
function.
1) Error with pytorch_model.bin
model_path = "pytorch_model.bin"
state_dict = torch.load(model_path, map_location="cpu")
state_dict = replace_OrderedDict(state_dict, prepend='model.')
model = YOLO()
model.load_state_dict(state_dict, strict=False)
> RuntimeError: Error(s) in loading state_dict for YOLO:
size mismatch for model.model.0.conv.weight: copying a param with shape torch.Size([80, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 3, 3, 3]).)
2) Error with model.safetensors
model_path = "model.safetensors"
state_dict = torch.load(model_path, map_location="cpu")
model = YOLO()
model.load_state_dict(state_dict, strict=False)
> UnpicklingError: could not find MARK