Are you sure you want to delete this access key?
comments | description | keywords |
---|---|---|
true | Learn how to set up and run Ultralytics YOLOv5 on AzureML. Follow this quickstart guide for easy configuration and model training on an AzureML compute instance. | YOLOv5, AzureML, machine learning, compute instance, quickstart, model training, virtual environment, Python, AI, deep learning, Ultralytics |
Welcome to the Ultralytics YOLOv5 quickstart guide for Microsoft Azure Machine Learning (AzureML)! This guide will walk you through setting up YOLOv5 on an AzureML compute instance, covering everything from creating a virtual environment to training and running inference with the model.
Azure is Microsoft's comprehensive cloud computing platform. It offers a vast array of services, including computing power, databases, analytics tools, machine learning capabilities, and networking solutions. Azure enables organizations to build, deploy, and manage applications and services through Microsoft-managed data centers, facilitating the migration of workloads from on-premises infrastructure to the cloud.
Azure Machine Learning (AzureML) is a specialized cloud service designed for developing, training, and deploying machine learning models. It provides a collaborative environment with tools suitable for data scientists and developers of all skill levels. Key features include automated machine learning (AutoML), a drag-and-drop interface for model creation, and a powerful Python SDK for more granular control over the ML lifecycle. AzureML simplifies the process of embedding predictive modeling into applications.
To follow this guide, you'll need an active Azure subscription and access to an AzureML workspace. If you don't have a workspace set up, please refer to the official Azure documentation to create one.
A compute instance in AzureML provides a managed cloud-based workstation for data scientists.
Once your compute instance is running, you can access its terminal directly from the AzureML studio.
Now, let's set up the environment and run Ultralytics YOLOv5.
It's best practice to use a virtual environment to manage dependencies. We'll use Conda, which is pre-installed on AzureML compute instances. For a detailed Conda setup guide, see the Ultralytics Conda Quickstart Guide.
Create a Conda environment (e.g., yolov5env
) with a specific Python version and activate it:
conda create --name yolov5env -y python=3.10 # Create a new Conda environment
conda activate yolov5env # Activate the environment
conda install pip -y # Ensure pip is installed
Clone the official Ultralytics YOLOv5 repository from GitHub using Git:
git clone https://github.com/ultralytics/yolov5 # Clone the repository
cd yolov5 # Navigate into the directory
# Initialize submodules (if any, though YOLOv5 typically doesn't require this step)
# git submodule update --init --recursive
Install the necessary Python packages listed in the requirements.txt
file. We also install ONNX for model export capabilities.
pip install -r requirements.txt # Install core dependencies
pip install onnx > =1.12.0 # Install ONNX for exporting
With the setup complete, you can now train, validate, perform inference, and export your YOLOv5 model.
Train the model on a dataset like COCO128. Check the Training Mode documentation for more details.
# Start training using yolov5s pretrained weights on the COCO128 dataset
python train.py --data coco128.yaml --weights yolov5s.pt --img 640 --epochs 10 --batch 16
Validate the trained model's performance using metrics like Precision, Recall, and mAP. See the Validation Mode guide for options.
# Validate the yolov5s model on the COCO128 validation set
python val.py --weights yolov5s.pt --data coco128.yaml --img 640
Run Inference on new images or videos. Explore the Prediction Mode documentation for various inference sources.
# Run inference with yolov5s on sample images
python detect.py --weights yolov5s.pt --source data/images --img 640
Export the model to different formats like ONNX, TensorRT, or CoreML for deployment. Refer to the Export Mode guide and the ONNX Integration page.
# Export yolov5s to ONNX format
python export.py --weights yolov5s.pt --include onnx --img 640
If you prefer an interactive experience, you can run these commands within an AzureML Notebook. You'll need to create a custom IPython kernel linked to your Conda environment.
Run the following commands in your compute instance terminal:
# Ensure your Conda environment is active
# conda activate yolov5env
# Install ipykernel if not already present
conda install ipykernel -y
# Create a new kernel linked to your environment
python -m ipykernel install --user --name yolov5env --display-name "Python (yolov5env)"
After creating the kernel, refresh your browser. When you open or create a .ipynb
notebook file, select your new kernel ("Python (yolov5env)") from the kernel dropdown menu at the top right.
Python Cells: Code in Python cells will automatically execute using the selected yolov5env
kernel.
Bash Cells: To run shell commands, use the %%bash
magic command at the beginning of the cell. Remember to activate your Conda environment within each bash cell, as they don't automatically inherit the notebook's kernel environment context.
%%bash
source activate yolov5env # Activate environment within the cell
# Example: Run validation using the activated environment
python val.py --weights yolov5s.pt --data coco128.yaml --img 640
Congratulations! You've successfully set up and run Ultralytics YOLOv5 on AzureML. For further exploration, consider checking out other Ultralytics Integrations or the detailed YOLOv5 documentation. You might also find the AzureML documentation useful for advanced scenarios like distributed training or model deployment as an endpoint.
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
ultralytics is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?