Roboflow Docs
DashboardResourcesProducts
  • Product Documentation
  • Developer Reference
  • Changelog
  • Developer Tools
  • Authentication
    • Find Your Roboflow API Key
    • Scoped API Keys
    • Workspace and Project IDs
  • Command Line Interface (CLI)
    • Using the CLI
    • Install and Set Up the CLI
    • List Workspaces and Projects
    • Download a Dataset
    • Upload a Dataset
    • Run a Model on an Image
  • REST API
    • Using the REST API
    • Authenticate with the REST API
    • List Workspaces and Projects
  • Search Images in a Dataset
  • Create a Project
  • Get a Project and List Versions
  • Manage Project Folders
  • List Image Batches
  • Create and List Annotation Jobs
  • Manage Images
    • Upload an Image
    • Get Details About an Image
    • Delete an Image from a Dataset
    • Upload an Annotation
    • Search for an Image
    • List, Add, and Remove Image Tags
  • Versions
    • View a Version
  • Export Data
  • Annotation Insights
    • Annotation Insights (Legacy Endpoint)
  • Model Monitoring
    • Retrieve Statistics About Deployed Models in a Workspace
    • Attach Metadata to an Inference
  • Python SDK
    • Using the Python SDK
  • Authenticate with the Python SDK
  • List Workspaces
  • List Projects and Versions
  • Create a Project
  • Create a Dataset Version
  • Train a Model
  • Upload a Dataset
  • Search for an Image
  • 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)
)
PreviousCreate a Dataset VersionNextUpload a Dataset

Was this helpful?