Zum Inhalt springen

Mastering YOLOv5 🚀 Einsatz auf 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.

Und wenn du ein neuer GCP-Benutzer bist, hast du Glück: Du bekommst ein kostenloses Guthaben von 300 Dollar, um deine Projekte zu starten.

Entdecken Sie neben GCP auch andere Schnellstartoptionen für YOLOv5, wie z. B. unsere Colab Notebook In Colab öffnen für ein browserbasiertes Erlebnis, oder die Skalierbarkeit von Amazon AWS. Außerdem können Container-Liebhaber unser offizielles Docker-Image unter Docker Hub Docker Pulls für eine gekapselte Umgebung.

Step 1: Create and Configure Your Deep Learning VM

Beginnen wir mit der Erstellung eines virtuellen Computers, der für Deep Learning optimiert ist:

  1. Gehe auf den GCP-Marktplatz und wähle die Deep Learning VM aus.
  2. Entscheide dich für eine n1-standard-8 Instanz; sie bietet ein Gleichgewicht von 8 vCPUs und 30 GB Speicher, ideal für unsere Bedürfnisse.
  3. Next, select a GPU. This depends on your workload; even a basic one like the T4 will markedly accelerate your model training.
  4. Aktiviere das Kontrollkästchen " NVIDIA GPU Treiber beim ersten Start automatisch installieren?", um eine problemlose Einrichtung zu gewährleisten.
  5. Weise eine 300 GB SSD Persistent Disk zu, um sicherzustellen, dass du keinen Engpass bei E/A-Operationen hast.
  6. Drücke auf "Bereitstellen" und lass GCP seine Magie bei der Bereitstellung deiner benutzerdefinierten Deep Learning-VM spielen.

Diese VM wird mit einem Schatz an vorinstallierten Tools und Frameworks ausgeliefert, darunter die Anaconda Python Distribution, die alle notwendigen Abhängigkeiten für YOLOv5 bündelt.

GCP Marketplace Illustration zum Einrichten einer Deep Learning VM

Schritt 2: Bereite die VM für YOLOv5

Nachdem wir die Umgebung eingerichtet haben, können wir YOLOv5 zum Laufen bringen:

# 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.

Schritt 3: Trainiere und setze deine YOLOv5 Modelle ein 🌐.

Wenn die Einrichtung abgeschlossen ist, kannst du mit YOLOv5 auf deiner GCP-VM mit dem Training und der Inferenz beginnen:

# 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.

Terminal-Befehlsbild, das das Modelltraining auf einer GCP Deep Learning VM zeigt

Zuweisung von Swap Space (optional)

Wenn du mit großen Datenmengen zu tun hast, solltest du deine GCP-Instanz mit zusätzlichen 64 GB Swap-Speicher erweitern:

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

Abschließende Überlegungen

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.

Vergiss nicht, deine Reise zu dokumentieren, Erkenntnisse mit der Ultralytics Community zu teilen und die kollaborativen Foren wie GitHub-Diskussionen zu nutzen, um weiter zu wachsen. Und nun geh los und erlebe Innovationen mit YOLOv5 und GCP! 🌟

Willst du deine ML-Fähigkeiten und dein Wissen weiter verbessern? In unserer Dokumentation und unseren Tutorials findest du weitere Ressourcen. Lass dein KI-Abenteuer weitergehen!

📅 Created 11 months ago ✏️ Updated 23 days ago

Kommentare