YOLOv5 ๋น ๋ฅธ ์์ ๐
Embark on your journey into the dynamic realm of real-time object detection with YOLOv5! This guide is crafted to serve as a comprehensive starting point for AI enthusiasts and professionals aiming to master YOLOv5. From initial setup to advanced training techniques, we've got you covered. By the end of this guide, you'll have the knowledge to implement YOLOv5 into your projects confidently. Let's ignite the engines and soar into YOLOv5!
์ค์น
๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ๋ณต์ ํ๊ณ ํ๊ฒฝ์ ์ค์ ํ์ฌ ์ถ์๋ฅผ ์ค๋นํฉ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ํ์ํ ๋ชจ๋ ์๊ตฌ ์ฌํญ์ด ์ค์น๋ฉ๋๋ค. ๋ค์์ด ์๋์ง ํ์ธํฉ๋๋ค. Python>=3.8.0 ๋ฐ PyTorch>=1.8 ์ด ์ค๋น๋์๋์ง ํ์ธํฉ๋๋ค.
git clone https://github.com/ultralytics/yolov5 # clone repository
cd yolov5
pip install -r requirements.txt # install dependencies
Inference with PyTorch Hub
์ต์ YOLOv5 ๋ฆด๋ฆฌ์ค์์ ๋ชจ๋ธ์ ์ํํ๊ฒ ๋ค์ด๋ก๋ํ ์ ์๋ YOLOv5 PyTorch ํ๋ธ ์ถ๋ก ์ ๊ฐํธํจ์ ๊ฒฝํํด ๋ณด์ธ์.
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.
detect.py๋ฅผ ์ฌ์ฉํ ์ถ๋ก
ํ๋ค์ค detect.py
๋ฅผ ์ฌ์ฉํ์ฌ ๋ค์ํ ์์ค์ ๋ํ ๋ค์ํ ์ถ๋ก ์ ์ํํ ์ ์์ต๋๋ค. ์๋์ผ๋ก ๋ค์์ ๊ฐ์ ธ์ต๋๋ค. ๋ชจ๋ธ ์ต์ YOLOv5 ๋ฆด๋ฆฌ์ค ๋ฅผ ํด๋ฆญํ๊ณ ๊ฒฐ๊ณผ๋ฅผ ์ฝ๊ฒ ์ ์ฅํ ์ ์์ต๋๋ค.
python detect.py --weights yolov5s.pt --source 0 # webcam
image.jpg # image
video.mp4 # video
screen # screenshot
path/ # directory
list.txt # list of images
list.streams # list of streams
'path/*.jpg' # glob
'https://youtu.be/LNwODJXcvt4' # YouTube
'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream
๊ต์ก
๋ณต์ YOLOv5 COCO ๋ฒค์น๋งํฌ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์๋ ์ง์นจ์ ์ฐธ์กฐํ์ธ์. ํ์ํ ๋ชจ๋ธ ๊ทธ๋ฆฌ๊ณ ๋ฐ์ดํฐ ์ธํธ ์์ ์ง์ ๊ฐ์ ธ์จ ๊ฒ์
๋๋ค. YOLOv5 ๋ฆด๋ฆฌ์ค. V100 GPU ์์ YOLOv5n/s/m/l/x๋ฅผ ๊ต์กํ๋ ๋ฐ๋ ์ผ๋ฐ์ ์ผ๋ก ๊ฐ๊ฐ 1/2/4/6/8์ผ์ด ์์๋ฉ๋๋ค. ๋ฉํฐGPU ์ค์ ์ด ๋ ๋น ๋ฅด๊ฒ ์๋ํฉ๋๋ค). ๊ฐ๋ฅํ ์ต๊ณ ์์ค์ --batch-size
๋๋ --batch-size -1
์ ๋ํ YOLOv5 ์๋ ๋ฐฐ์น feature. The following batch sizes are ideal for V100-16GB GPUs.
python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov5n.yaml --batch-size 128
yolov5s 64
yolov5m 40
yolov5l 24
yolov5x 16
To conclude, YOLOv5 is not only a state-of-the-art tool for object detection but also a testament to the power of machine learning in transforming the way we interact with the world through visual understanding. As you progress through this guide and begin applying YOLOv5 to your projects, remember that you are at the forefront of a technological revolution, capable of achieving remarkable feats. Should you need further insights or support from fellow visionaries, you're invited to our GitHub repository home to a thriving community of developers and researchers. Keep exploring, keep innovating, and enjoy the marvels of YOLOv5. Happy detecting! ๐ ๐