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
272 stars 71 forks source link

Model Upload Failed when EMA activated in model #250

Open gurbain opened 4 months ago

gurbain commented 4 months ago

Hello,

I'm trying to uplad a custom trained model based on yolov8l on roboflow in order to make my annotating process simpler. I have trained my model using ultralytics v8.2.2.

However, when I try to use the deploy function, I get the following error:

  File "[...]/python3.10/site-packages/roboflow/core/version.py", line 468, in deploy
    if isinstance(model["model"].names, list):
AttributeError: 'NoneType' object has no attribute 'names'

After some research, I realized that my model's weight are saved in model["ema"] and not in model["model"]. I replaced it and it simply like this in the file versions.py:

        elif "yolov5" in model_type or "yolov7" in model_type or "yolov9" in model_type:
            try:
                import torch
            except ImportError:
                raise (
                    "The torch python package is required to deploy yolov5 models."
                    " Please install it with `pip install torch`"
                )

        model = torch.load(os.path.join(model_path, filename))
        model["model"] = model["ema"]

Now, it uploads but I get the following error on the Roboflow platform:

Model Upload Failed
This model upload failed. A failure usually occurs because of an older, incompatible model version or possibly a new type we don't currently have support for.

I can't find how to disable EMA during training. Is there anything I can do to make this work? Best regards!