Перейти к содержимому

Mastering YOLOv5 🚀 Deployment on Google Cloud Platform (GCP) Deep Learning Virtual Machine (VM) ⭐.

Embarking on the journey of artificial intelligence and machine learning can be exhilarating, especially when you leverage the power and flexibility of a cloud platform. Google Cloud Platform (GCP) offers robust tools tailored for machine learning enthusiasts and professionals alike. One such tool is the Deep Learning VM that is preconfigured for data science and ML tasks. In this tutorial, we will navigate through the process of setting up YOLOv5 on a GCP Deep Learning VM. Whether you're taking your first steps in ML or you're a seasoned practitioner, this guide is designed to provide you with a clear pathway to implementing object detection models powered by YOLOv5.

🆓 К тому же, если ты только что стал пользователем GCP, тебе повезло: тебе предлагают бесплатный кредит в 300 долларов, чтобы дать старт твоим проектам.

Помимо GCP, изучи другие доступные варианты быстрого старта для YOLOv5, например, наш Блокнот Colab Open In Colab для работы в браузере, или масштабируемость Amazon AWS. Кроме того, любители контейнеров могут использовать наш официальный образ Docker по адресу Docker Hub Docker Pulls для инкапсулированной среды.

Step 1: Create and Configure Your Deep Learning VM

Начнем с создания виртуальной машины, настроенной на глубокое обучение:

  1. Перейди на торговую площадку GCP и выбери виртуальную машину Deep Learning VM.
  2. Выбирай экземпляр n1-standard-8; он предлагает баланс из 8 vCPU и 30 Гб памяти, идеально подходящий для наших нужд.
  3. Next, select a GPU. This depends on your workload; even a basic one like the T4 will markedly accelerate your model training.
  4. Поставь галочку в поле 'Установить драйвер NVIDIA GPU автоматически при первом запуске?', чтобы установка прошла без проблем.
  5. Выдели 300 Гб SSD Persistent Disk, чтобы не допустить узких мест в операциях ввода-вывода.
  6. Нажми "Deploy" и позволь GCP сделать свою магию в обеспечении твоей пользовательской ВМ Deep Learning.

Эта ВМ поставляется с кладезем предустановленных инструментов и фреймворков, включая дистрибутив Anaconda Python , в котором удобно собраны все необходимые зависимости для YOLOv5.

Иллюстрация GCP Marketplace по настройке виртуальной машины Deep Learning VM

Шаг 2: Подготовь виртуальную машину к YOLOv5

После настройки окружения давай запустим YOLOv5 :

# Clone the YOLOv5 repository
git clone https://github.com/ultralytics/yolov5

# Change the directory to the cloned repository
cd yolov5

# Install the necessary Python packages from requirements.txt
pip install -r requirements.txt

This setup process ensures you're working with a Python environment version 3.8.0 or newer and PyTorch 1.8 or above. Our scripts smoothly download models and datasets rending from the latest YOLOv5 release, making it hassle-free to start model training.

Шаг 3: Обучи и разверни свои модели YOLOv5 🌐.

Настройка завершена, и ты готов приступить к обучению и созданию выводов с помощью YOLOv5 на своей виртуальной машине GCP:

# Train a model on your data
python train.py

# Validate the trained model for Precision, Recall, and mAP
python val.py --weights yolov5s.pt

# Run inference using the trained model on your images or videos
python detect.py --weights yolov5s.pt --source path/to/images

# Export the trained model to other formats for deployment
python export.py --weights yolov5s.pt --include onnx coreml tflite

With just a few commands, YOLOv5 allows you to train custom object detection models tailored to your specific needs or utilize pre-trained weights for quick results on a variety of tasks.

Изображение команды терминала, иллюстрирующее обучение модели на виртуальной машине GCP Deep Learning VM

Распределите место подкачки (необязательно)

Для тех, кто работает с большими массивами данных, подумай о том, чтобы усилить свой экземпляр GCP дополнительными 64 Гб памяти подкачки:

sudo fallocate -l 64G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h  # confirm the memory increment

Заключительные мысли

Congratulations! You are now empowered to harness the capabilities of YOLOv5 with the computational prowess of Google Cloud Platform. This combination provides scalability, efficiency, and versatility for your object detection tasks. Whether for personal projects, academic research, or industrial applications, you have taken a pivotal step into the world of AI and machine learning on the cloud.

Не забывай документировать свой путь, делиться впечатлениями с сообществом Ultralytics и использовать такие арены для совместной работы, как обсуждения на GitHub, чтобы развиваться дальше. А теперь вперед, к инновациям с YOLOv5 и GCP! 🌟

Хочешь и дальше совершенствовать свои навыки и знания в области ML? Погрузись в нашу документацию и учебники, чтобы найти больше ресурсов. Пусть твои приключения в области ИИ продолжаются!

📅 Created 11 months ago ✏️ Updated 24 days ago

Комментарии