Link to this sectionYOLOv5 クイックスタート 🚀#
Ultralytics YOLOv5 で、リアルタイム物体検出のダイナミックな世界へ足を踏み入れましょう!このガイドは、YOLOv5 を習得しようとする AI 愛好家や専門家にとっての包括的なスタート地点となるように作成されています。初期セットアップから高度な学習テクニックまで、すべてを網羅しています。このガイドを読み終える頃には、最先端のディープラーニング手法を用いて、自信を持って YOLOv5 をプロジェクトに実装する知識が身についているはずです。エンジンを始動し、YOLOv5 の世界へ飛び立ちましょう!
Link to this sectionインストール#
YOLOv5 リポジトリをクローンし、環境を構築して打ち上げの準備をしましょう。これにより、必要なすべての要件がインストールされます。Python>=3.8.0 と PyTorch>=1.8 が準備できていることを確認してください。これらの基礎ツールは、YOLOv5 を効果的に実行するために不可欠です。
git clone https://github.com/ultralytics/yolov5 # clone repository
cd yolov5
pip install -r requirements.txt # install dependenciesLink to this sectionPyTorch Hub による推論#
Experience the simplicity of YOLOv5 PyTorch Hub inference, where models are seamlessly downloaded from the latest YOLOv5 release. This method leverages the power of PyTorch for easy model loading and execution, making it straightforward to get predictions.
import torch
# Model loading
model = torch.hub.load("ultralytics/yolov5", "yolov5s") # Can be 'yolov5n' - 'yolov5x6', or 'custom'
# Inference on images
img = "https://ultralytics.com/images/zidane.jpg" # Can be a file, Path, PIL, OpenCV, numpy, or list of images
# Run inference
results = model(img)
# Display results
results.print() # Other options: .show(), .save(), .crop(), .pandas(), etc. Explore these in the Predict mode documentation.Link to this sectiondetect.py による推論#
Harness detect.py for versatile inference on various sources. It automatically fetches models from the latest YOLOv5 release and saves results with ease. This script is ideal for command-line usage and integrating YOLOv5 into larger systems, supporting inputs like images, videos, directories, webcams, and even live streams.
python detect.py --weights yolov5s.pt --source 0 # webcam
python detect.py --weights yolov5s.pt --source image.jpg # image
python detect.py --weights yolov5s.pt --source video.mp4 # video
python detect.py --weights yolov5s.pt --source screen # screenshot
python detect.py --weights yolov5s.pt --source path/ # directory
python detect.py --weights yolov5s.pt --source list.txt # list of images
python detect.py --weights yolov5s.pt --source list.streams # list of streams
python detect.py --weights yolov5s.pt --source 'path/*.jpg' # glob pattern
python detect.py --weights yolov5s.pt --source 'https://youtu.be/LNwODJXcvt4' # YouTube video
python detect.py --weights yolov5s.pt --source 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP streamLink to this sectionトレーニング#
Replicate the YOLOv5 COCO dataset benchmarks by following the training instructions below. The necessary models and datasets (like coco128.yaml or the full coco.yaml) are pulled directly from the latest YOLOv5 release. Training YOLOv5n/s/m/l/x on a V100 GPU should typically take 1/2/4/6/8 days respectively (note that Multi-GPU training setups work faster). Maximize performance by using the highest possible --batch-size or use --batch-size -1 for the YOLOv5 AutoBatch feature, which automatically finds the optimal batch size. The following batch sizes are ideal for V100-16GB GPUs. Refer to our configuration guide for details on model configuration files (*.yaml).
# Train YOLOv5n on COCO128 for 3 epochs
python train.py --data coco128.yaml --epochs 3 --weights yolov5n.pt --batch-size 128
# Train YOLOv5s on COCO for 300 epochs
python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5s.yaml --batch-size 64
# Train YOLOv5m on COCO for 300 epochs
python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5m.yaml --batch-size 40
# Train YOLOv5l on COCO for 300 epochs
python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5l.yaml --batch-size 24
# Train YOLOv5x on COCO for 300 epochs
python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5x.yaml --batch-size 16
最後に、YOLOv5 は単なる最先端の物体検出ツールであるだけでなく、視覚的理解を通じて世界との関わり方を変革する機械学習の力の証でもあります。このガイドを通じて学び、YOLOv5 をプロジェクトに適用し始めるにあたり、あなたが技術革命の最前線に立ち、コンピュータビジョンにおいて驚くべき成果を達成できる可能性を秘めていることを忘れないでください。さらなる洞察や、他の先見的な開発者からのサポートが必要な場合は、開発者や研究者の活気あるコミュニティの拠点である GitHub リポジトリへ招待します。コード不要のデータセット管理やモデル学習のための Ultralytics プラットフォーム などのリソースをさらに探索するか、実際のアプリケーションやインスピレーションを得るために ソリューション ページをご覧ください。探求と革新を続け、YOLOv5 の驚異を楽しんでください。ハッピー・ディテクティング! 🌠🔍