I am trying to upload my YOLOV8 weights to roboflow.
I keep getting this error.
Here is a bit more of the error
loading Roboflow workspaceâŚ
loading Roboflow projectâŚ
Traceback (most recent call last):
File â/Users/boazburnett/PycharmProjects/Roboflow Testing/main.pyâ, line 6, in
project.version(3).deploy(model_type=âyolov8â, model_path=â/Users/boazburnett/PycharmProjects/Roboflow Testing/runs/classify/trainâ)
File â/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/roboflow/core/version.pyâ, line 478, in deploy
model = torch.load(os.path.join(model_path, âweights/best.ptâ))
File â/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/torch/serialization.pyâ, line 809, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File â/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/torch/serialization.pyâ, line 1172, in _load
result = unpickler.load()
File â/Users/boazburnett/PycharmProjects/Roboflow Testing/venv/lib/python3.9/site-packages/torch/serialization.pyâ, line 1165, in find_class
return super().find_class(mod_name, name)
ModuleNotFoundError: No module named âultralytics.dataâ
And my code
from roboflow import Roboflow
rf = Roboflow(api_key=âsecretâ)
project = rf.workspace(âboaztheostrichâ).project(âcartest-tyaurâ)
The error youâre encountering seems to be related to the PyTorch library not being able to find the âultralytics.dataâ module. This issue is not directly related to Roboflow but rather to the dependencies of your YOLOv8 model.
However, to upload your YOLOv8 weights to Roboflow, you can follow these steps:
Ensure that you have the correct version of the Roboflow Python package. You need the roboflow>=1.0.1 Python package version to use the .deploy() command (source).
Make sure your weights are in the correct directory. According to the Roboflow blog, the weights should be in the â/runs/detect/train/weights/best.ptâ folder of your project.
Replace âAPI_KEYâ, âPROJECT_IDâ, and âDATASET_VERSIONâ with your actual API key, project ID, and dataset version respectively.
If you continue to encounter issues, it might be helpful to check the Roboflow documentation or reach out to their support for further assistance.
Hi! Iâm Roboflowâs AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, knowledge base, and previous forum responses. If you find this to be a helpful answer, please mark it as the solution using the checkbox icon below. If this doesnât solve your issue, please follow up with what youâve tried/why, and the community will continue to chime in as usual.
Hi @Boaztheostrich ! Iâve seen this error when the version of ultralytics Iâm using with the roboflow python package doesnât match the version of ultralytics I used to train my model.
Hi @Paul thanks for the response! I think that was the solution however I am now getting an error code talking about nc?
It relates to this code within version.py
if "yolov8" in model_type:
# try except for backwards compatibility with older versions of ultralytics
if "-cls" in model_type:
nc = model["model"].yaml["nc"]
args = model["train_args"]
else:
nc = model["model"].nc
args = model["model"].args
try:
model_artifacts = {
"names": class_names,
"yaml": model["model"].yaml,
"nc": nc,
"args": {
k: val
for k, val in args.items()
if ((k == "model") or (k == "imgsz") or (k == "batch"))
},
"ultralytics_version": ultralytics.__version__,
"model_type": model_type,
}
When I changed the model name to âyolov8-clsâ it did successfully upload however all of my predictions were at 0% MAP etc.