roboflow / roboflow-python

The official Roboflow Python package. Manage your datasets, models, and deployments. Roboflow has everything you need to build a computer vision application.
https://docs.roboflow.com/python
Apache License 2.0
311 stars 77 forks source link

Fix yolov10 version deploy #319

Closed grzegorz-roboflow closed 2 months ago

grzegorz-roboflow commented 2 months ago

Description

Below results in error:

python3.9 -m venv venv
source venv/bin/activate
pip install -e .
import roboflow

rf = roboflow.Roboflow(api_key="<redacted>")

workspace = rf.workspace(the_workspace="<my workspace ID>")
proj = workspace.project(project_id="<my prioject ID>")
version = proj.version(1)

version.deploy(
    model_type="yolov10",
    model_path="/path/to/my_yolov10_dir",
    filename="my_model.pt",
)

Above results in following exception:

Traceback (most recent call last):
  File "/path/to/my_script.py", line 10, in <module>
    version.deploy(
  File "/path/to/roboflow-python/roboflow/core/version.py", line 522, in deploy
    model = torch.load(os.path.join(model_path, filename))
  File "/path/to/roboflow-python/venv/lib/python3.9/site-packages/ultralytics/utils/patches.py", line 86, in torch_load
    return _torch_load(*args, **kwargs)
  File "/path/to/roboflow-python/venv/lib/python3.9/site-packages/torch/serialization.py", line 1097, in load
    return _load(
  File "/path/to/roboflow-python/venv/lib/python3.9/site-packages/torch/serialization.py", line 1525, in _load
    result = unpickler.load()
  File "/path/to/roboflow-python/venv/lib/python3.9/site-packages/torch/serialization.py", line 1515, in find_class
    return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'YOLOv10DetectionModel' on <module 'ultralytics.nn.tasks' from '/path/to/roboflow-python/venv/lib/python3.9/site-packages/ultralytics/nn/tasks.py'>

Type of change

How has this change been tested, please provide a testcase or example of how you tested the change?

Executed above-mentioned script from branch with fix applied

Any specific deployment considerations

N/A

Docs