How do I upload annotated dataset from Roboflow to Custom Vision Project?

Maheen Rasool 0 Reputation points
2025-06-28T17:23:18.78+00:00

Roboflow allows to download dataset with annotations in different formats. I have a annotated dataset there that I want to upload to Custom Vision. Is this possible? If so please let me know how?

Azure AI Custom Vision
Azure AI Custom Vision
An Azure artificial intelligence service and end-to-end platform for applying computer vision to specific domains.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prashanth Veeragoni 5,745 Reputation points Microsoft External Staff Moderator
    2025-06-30T04:22:17.0933333+00:00

    Hello Maheen Rasool,

    Yes, you can upload an annotated dataset from Roboflow to a Custom Vision project in Azure, but the process is not directly seamless because Azure Custom Vision expects a specific format. Here's a step-by-step explanation on how to make it work:

    Step-by-Step Guide: Upload Roboflow Dataset to Azure Custom Vision

    Step1: Download Dataset from Roboflow

    ·       In your Roboflow project:

    o   Click Export Dataset.

    o   Choose the format: Select "VOC XML" (Pascal VOC format), which is supported by Azure Custom Vision.

    o   Choose image size (original size is preferred).

    o   Download the ZIP file.

    Step2: Understand Azure Custom Vision Requirements

    Azure Custom Vision accepts:

    ·       Images (.jpg, .png, etc.)

    ·       Annotation file: For object detection, it accepts Pascal VOC (XML files with bounding boxes).

    ·       All images and XML files should be uploaded via the Custom Vision Portal or Python SDK / REST API.

    Step3: Extract and Organize the Dataset

    After unzipping the dataset:

    ·       You’ll get two folders:

    o   images/ – contains image files

    o   annotations/ – contains Pascal VOC XML files

    Make sure:

    ·       Each image has a corresponding .xml annotation file with the same name (e.g., car_001.jpg ↔ car_001.xml).

    ·       All files are clean and consistent.

    Step4: Create a Custom Vision Project

    1.      Go to the Azure Custom Vision Portal.

    2.      Click New Project.

    3.      Choose:

    o   Project Type: Object Detection

    o   Domain: General (or Retail, etc., based on your use-case)

    o   Resource Group & Training Resource: As configured in Azure.

    Step5: Upload Data to Custom Vision

    Option1: Using Azure Custom Vision Portal (GUI)

    ·       Not ideal for large datasets with annotations.

    ·       You can upload images and manually tag them – time-consuming.

    Option2: Use the Custom Vision Python SDK

    Here’s a basic script to upload images + Pascal VOC annotations:

    from azure.cognitiveservices.vision.customvision.training import CustomVisionTrainingClient
    from msrest.authentication import ApiKeyCredentials
    import os
    # Setup
    ENDPOINT = "https://<your-customvision-endpoint>.cognitiveservices.azure.com/"
    TRAINING_KEY = "<your-training-key>"
    PROJECT_ID = "<your-project-id>"
    credentials = ApiKeyCredentials(in_headers={"Training-key": TRAINING_KEY})
    trainer = CustomVisionTrainingClient(ENDPOINT, credentials)
    # Upload dataset
    images_folder = "images"
    annotations_folder = "annotations"
    for image_filename in os.listdir(images_folder):
        if image_filename.endswith(".jpg"):
            image_path = os.path.join(images_folder, image_filename)
            annotation_path = os.path.join(annotations_folder, image_filename.replace(".jpg", ".xml"))
            
            with open(image_path, "rb") as image_contents:
                regions = trainer.create_regions_from_voc(annotation_path)
                trainer.create_images_from_data(
                    project_id=PROJECT_ID,
                    images=[{
                        "name": image_filename,
                        "contents": image_contents,
                        "regions": regions
                    }]
                )
    

    Step6: Train Your Model

    Once images are uploaded with bounding boxes:

    ·       Click Train in the portal or use:

    iteration = trainer.train_project(PROJECT_ID)
    
    

    Attaching links below for your reference

    https://docs.roboflow.com/datasets/dataset-versions/exporting-data

    https://customvision.ai/projects

    Hope this helps, please do up-vote and accept if this helps in resolving your query.

    Thank you!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.