Roboflow Docs
DashboardResourcesProducts
  • Documentation
  • Developer Reference
  • Changelog
  • Developer Tools
  • Authentication
  • Command Line Interface (CLI)
    • Using the CLI
    • Installation and Authentication
    • Download dataset
    • Upload Dataset
    • Run inference
    • Getting help
  • REST API
    • REST API Structure
    • Workspace and Project IDs
    • Workspaces
  • Workspace Image Query
  • Projects
    • Initialize
    • Project Folders API
    • Create
  • Batches
  • Annotation Jobs
  • Images
    • Upload Images
    • Image Details
    • Upload Dataset
    • Upload an Annotation
    • Search
    • Tags
  • Versions
    • Create a Project Version
    • View a Version
  • Train a Model
  • Export Data
  • Inference
  • Annotation Insights
    • Annotation Insights (Legacy Endpoint)
  • Model Monitoring
    • Stats
    • Custom Metadata
  • Python SDK
    • Using the Python SDK
  • iOS SDK
    • Using the iOS SDK
Powered by GitBook
On this page

Was this helpful?

Train a Model

You can start a training job either in the Roboflow platform or using the Python SDK, using the instructions below.

To schedule a training job via the Python SDK, use the train() method on the version of your dataset for which you would like to train your model. Note: this code initiates training on the Roboflow platform asynchronously, and the code will finish executing before training completes.

import roboflow

rf = roboflow.Roboflow(api_key=YOUR_API_KEY_HERE)

# List all projects for your workspace
workspace = rf.workspace()

# get a project
project = rf.workspace().project("PROJECT_ID")

# Create a new version with custom preprocessing and augmentation
new_version = project.generate_version(
    preprocessing={
        "auto-orient": True,
        "resize": {"width": 640, "height": 640, "format": "Stretch to"},
        "grayscale": False
    },
    augmentation={
    }
)
version = project.version(new_version)

# Train on the version with specific training parameters
model = version.train(
    speed="fast",          # Options: "fast" (default) or "accurate" (paid feature)
    checkpoint=None,       # Use a specific checkpoint to continue training
    plot_in_notebook=False # Visualize training progress (for notebooks)
)
PreviousView a VersionNextExport Data

Was this helpful?