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!