Computer vision answers · Data Labeling

How do I add a new class to an existing computer vision model without losing my labels?

Without starting your dataset over from scratch.

Short answer

Add the new class to your existing Roboflow project for free, label it on the images you already have as well as new ones, then train a new model version. Your existing labels stay, and Auto Label can add the new class to labeled images without replacing them. Label the new class on every image where it appears, including images you labeled before, because an unlabeled object teaches the model that it is background.

Roboflow agent · free to start

Skip the setup. Describe your images.

Describe your images and what you need to find. The agent sets up labeling, training and deployment with you.

Key facts

What you need
Your labeled dataset, plus images that show the new class
What you get
A new model version that finds the old classes and the new one
Image sources
Your existing project, new uploads and Roboflow Universe
Runs on
Cloud API, or your own device or server running Docker
Object detection highlighting a worker's hard hat, vest, and gloves as he holds a box in a warehouse.

How to add a new class, step by step

Six steps from your current dataset to a model that knows one more class.

  1. Connect Roboflow to your coding agent, ChatGPT or Codex

    Add the Roboflow MCP server to Claude, Cursor or Gemini CLI, or install the Roboflow plugin in ChatGPT or Codex. Your assistant can then upload images, auto-label the new class, start training and test the new model from a prompt, at no extra cost beyond your Roboflow plan.

  2. Upload images that show the new class to the same project

    Add images of the new class to the project that holds your current dataset, so every existing label stays in place. Use varied examples of the new class, taken in the same conditions the model will see.

  3. Add the new class to the images you already labeled

    Run Auto Label in Roboflow Annotate with SAM 3 and a text prompt that describes the new class. When it asks what to do with existing annotations, choose to keep or merge them, not replace them, then review the labels it added.

  4. Label every object on the new images

    On the images you just uploaded, label the existing classes as well as the new one. New images with only the new class labeled would teach the model to ignore the classes it already knows.

  5. Create a new dataset version and train

    Generate a new dataset version. A version is a snapshot of your images and labels, so the earlier version stays as it was. Train an RF-DETR model on the new version with Roboflow Train.

  6. Check the new model finds every class

    Run the new model on a test image that contains both the old classes and the new one, and count what it finds by class name.

    Python
    import supervision as sv
    from collections import Counter
    from inference import get_model
    
    model = get_model("your-project/2")
    
    result = model.infer("test_image.jpg", confidence=0.4)[0]
    detections = sv.Detections.from_inference(result)
    
    print(Counter(detections.data["class_name"]))
    # Counter({'hard-hat': 5, 'vest': 4, 'gloves': 3})

    Rather not write code? Ask the Roboflow agent to set this up for you

Why 2 million engineers build on Roboflow

  • Label faster

    Auto-label with SAM 3 or your own model, then fix the misses instead of drawing every box.

  • RF-DETR

    Roboflow’s open-source real-time detection model, built for accuracy (opens in a new tab) on small objects.

  • Logic built in

    Counting, zones, tracking and alerts are ready-made Workflow blocks, so there is less code to write.

  • Your model, your weights

    Use your trained weights on every plan, including free, through the open-source Inference package.

  • Run it anywhere

    Self-host on a workstation, Docker, an on-prem GPU or an edge device, or call the cloud API.