Train a Model

Version.train() schedules training on the Roboflow platform. The call returns once the job is queued — training itself runs asynchronously.

import roboflow

rf = roboflow.Roboflow(api_key="YOUR_API_KEY")
project = rf.workspace().project("my-detector")

# Create a version with preprocessing and augmentation if you don't have one yet.
new_version = project.generate_version({
    "preprocessing": {
        "auto-orient": True,
        "resize": {"width": 640, "height": 640, "format": "Stretch to"},
    },
    "augmentation": {},
})
version = project.version(new_version)

# Schedule training.
model = version.train(
    model_type="rfdetr-nano",   # pass an invalid value to get the full list back as an error
    checkpoint=None,             # optional: resume from a previous checkpoint
    epochs=100,                  # optional: defaults are model-type-dependent
    plot_in_notebook=False,      # display a training-progress plot (notebook only)
)

Parameters

  • model_type (str) — architecture identifier. Common values: rfdetr-nano, rfdetr-base, yolov8, yolov11. Project-type dependent. Pass an invalid value to get the full list back as an error.

  • speed (str, optional) — "fast" (default) or "accurate". Accurate training is a paid feature.

  • checkpoint (str, optional) — id of a checkpoint to resume from.

  • epochs (int, optional) — number of epochs. Defaults are model-type-dependent.

  • plot_in_notebook (bool, default False) — display training progress inline (notebook only).

After training

Once training completes, the Version's .model property returns the hosted model:

See Run a Model on an Image for the full inference reference.

Last updated

Was this helpful?