Upload Custom Weights

Roboflow offers the ability to upload model weights for your custom-trained models to your Roboflow projects for model deployment.

Once you've completed training your custom model, upload your model weights back to your Roboflow project to take advantage of Roboflow Inference.

YOLOv8 models must be trained on ultralytics==8.0.196

YOLOv11 models must be trained on ultralytics>=8.3.0

Model weights uploads are currently available for:

  • YOLOv5 (n, s, m, l, x) Object Detection and Instance Segmentation

  • YOLOv7 Instance Segmentation (yolov7-seg)

  • YOLOv8 (n, s, m, l, x) Object Detection, Instance Segmentation, Classification, and Keypoint Detection

  • YOLOv9 (n, s, m, l, x) Object Detection

  • YOLOv10 (n, s, m, l, x) Object Detection

  • YOLOv11 (n, s, m, l, x) Object Detection, Instance Segmentation

  • YOLO-NAS (s, m, l) Object Detection

After successfully training your model, use the .deploy() function to upload your model weights back to your Roboflow Object Detection project.

Model weights uploads are only available for dataset versions without a trained model (i.e not yet trained with Roboflow Train, and no model weights uploaded).

NOTE: Larger model sizes provide better training results. However, the larger the model size, the slower the training time, and inference (model prediction) speed. Consider whether you're looking for real-time inference on fast-moving objects or video feeds (better to use a smaller model), or you are processing data after it is collected, and more concerned with higher prediction accuracy (choose a larger model).

Upload Custom Weights

You need roboflow>=1.0.1 to use the.deploy() command.

To upload custom weights, use the model.deploy() method in the Python SDK.

import roboflow

rf = roboflow.Roboflow(api_key=YOUR_API_KEY_HERE)
project = rf.workspace().project("PROJECT_ID")

#can specify weights_filename, default is "weights/best.pt"
version = project.version(VERSION_ID)
version.deploy("model-type", "path/to/training/results/", "weights_filename")

#example1 - directory path is "training1/model1.pt" for yolov8 model
version.deploy("yolov8", "training1", "model1.pt")

#example2 - directory path is "training1/weights/best.pt" for yolov8 model
version.deploy("yolov8", "training1")

The following model types are supported:

  • yolov5, yolov5-seg

  • yolov7, yolov7-seg

  • yolov8, yolov8-seg, yolov8-cls, yolov8-pose

  • yolov9

  • yolov10

  • yolonas

  • yolov11 (for all task types)

If weights upload is attempted for dataset versions that already have a trained model (a Roboflow Train model or uploaded custom model) then you will receive a RuntimeError - "This version already has a trained model. Please generate and train a new version in order to upload model to Roboflow."

If upload is attempted for a model architecture that is not yet supported for weights upload, then you will receive a ValueError.

Next Steps

  1. Test your model in the Deploy Tab.

  2. Run your model locally with Roboflow Inference Server.

  3. Deploy your Model with Roboflow Deploy.

  4. Improve your Model with Active Learning.

Last updated