Link to this sectionAzureML์์์ Ultralytics YOLOv5 ๐ ํต์คํํธ#
Microsoft Azure Machine Learning(AzureML)์ ์ํ Ultralytics YOLOv5 ํต์คํํธ ๊ฐ์ด๋์ ์ค์ ๊ฒ์ ํ์ํฉ๋๋ค! ์ด ๊ฐ์ด๋๋ AzureML ์ปดํจํ ์ธ์คํด์ค์์ YOLOv5๋ฅผ ์ค์ ํ๊ณ ๊ฐ์ ํ๊ฒฝ ์์ฑ๋ถํฐ ๋ชจ๋ธ ํ์ต ๋ฐ ์ถ๋ก ์คํ๊น์ง์ ๋ชจ๋ ๊ณผ์ ์ ์๋ดํฉ๋๋ค.
Link to this sectionAzure๋ ๋ฌด์์ธ๊ฐ์?#
Azure๋ Microsoft์ ์ข ํฉ ํด๋ผ์ฐ๋ ์ปดํจํ ํ๋ซํผ์ ๋๋ค. ์ด ํ๋ซํผ์ ์ปดํจํ ์ฑ๋ฅ, ๋ฐ์ดํฐ๋ฒ ์ด์ค, ๋ถ์ ๋๊ตฌ, ๋จธ์ ๋ฌ๋ ๊ธฐ๋ฅ ๋ฐ ๋คํธ์ํน ์๋ฃจ์ ์ ํฌํจํ ๊ด๋ฒ์ํ ์๋น์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. Azure๋ฅผ ํตํด ์กฐ์ง์ Microsoft๊ฐ ๊ด๋ฆฌํ๋ ๋ฐ์ดํฐ ์ผํฐ๋ฅผ ํ์ฉํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ์๋น์ค๋ฅผ ๊ตฌ์ถ, ๋ฐฐํฌ ๋ฐ ๊ด๋ฆฌํ ์ ์์ผ๋ฉฐ ์จํ๋ ๋ฏธ์ค ์ธํ๋ผ์์ ํด๋ผ์ฐ๋๋ก์ ์ํฌ๋ก๋ ๋ง์ด๊ทธ๋ ์ด์ ์ ์ง์ํฉ๋๋ค.
Link to this sectionAzure Machine Learning(AzureML)์ด๋ ๋ฌด์์ธ๊ฐ์?#
Azure Machine Learning(AzureML)์ ๋จธ์ ๋ฌ๋ ๋ชจ๋ธ์ ๊ฐ๋ฐ, ํ์ต ๋ฐ ๋ฐฐํฌ๋ฅผ ์ํด ์ค๊ณ๋ ํน์ ํด๋ผ์ฐ๋ ์๋น์ค์ ๋๋ค. ๋ชจ๋ ๊ธฐ์ ์์ค์ ๋ฐ์ดํฐ ๊ณผํ์์ ๊ฐ๋ฐ์์๊ฒ ์ ํฉํ ๋๊ตฌ์ ํ์ ํ๊ฒฝ์ ์ ๊ณตํฉ๋๋ค. ์ฃผ์ ๊ธฐ๋ฅ์ผ๋ก๋ ์๋ ๋จธ์ ๋ฌ๋(AutoML), ๋ชจ๋ธ ์์ฑ์ ์ํ ๋๋๊ทธ ์ค ๋๋กญ ์ธํฐํ์ด์ค, ๊ทธ๋ฆฌ๊ณ ML ์๋ช ์ฃผ๊ธฐ๋ฅผ ๋ณด๋ค ์ธ๋ฐํ๊ฒ ์ ์ดํ ์ ์๋ ๊ฐ๋ ฅํ Python SDK๊ฐ ์์ต๋๋ค. AzureML์ ์์ธก ๋ชจ๋ธ๋ง์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ด์ฅํ๋ ๊ณผ์ ์ ๊ฐ์ํํฉ๋๋ค.
Link to this section์ฌ์ ์๊ตฌ ์ฌํญ#
์ด ๊ฐ์ด๋๋ฅผ ๋ฐ๋ผ ํ๋ ค๋ฉด ํ์ฑํ๋ Azure ๊ตฌ๋ ๊ณผ AzureML ์์ ์์ญ(workspace)์ ๋ํ ์ก์ธ์ค ๊ถํ์ด ํ์ํฉ๋๋ค. ์์ง ์์ ์์ญ์ด ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ ๊ณต์ Azure ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ฌ ์์ฑํ์ญ์์ค.
Link to this section์ปดํจํ ์ธ์คํด์ค ์์ฑ#
AzureML์ ์ปดํจํ ์ธ์คํด์ค๋ ๋ฐ์ดํฐ ๊ณผํ์๋ฅผ ์ํ ๊ด๋ฆฌํ ํด๋ผ์ฐ๋ ๊ธฐ๋ฐ ์ํฌ์คํ ์ด์ ์ ์ ๊ณตํฉ๋๋ค.
- AzureML ์์ ์์ญ์ผ๋ก ์ด๋ํฉ๋๋ค.
- ์ผ์ชฝ ์ฐฝ์์ **Compute(์ปดํจํ )**๋ฅผ ์ ํํฉ๋๋ค.
- Compute instances(์ปดํจํ ์ธ์คํด์ค) ํญ์ผ๋ก ์ด๋ํ์ฌ **New(์๋ก ๋ง๋ค๊ธฐ)**๋ฅผ ํด๋ฆญํฉ๋๋ค.
- ํ์ต ๋๋ ์ถ๋ก ์ ํ์ํ ์๊ตฌ ์ฌํญ์ ๋ฐ๋ผ ์ ์ ํ CPU ๋๋ GPU ๋ฆฌ์์ค๋ฅผ ์ ํํ์ฌ ์ธ์คํด์ค๋ฅผ ๊ตฌ์ฑํฉ๋๋ค.
Link to this sectionํฐ๋ฏธ๋ ์ด๊ธฐ#
์ปดํจํ ์ธ์คํด์ค๊ฐ ์คํ๋๋ฉด AzureML ์คํ๋์ค์์ ์ง์ ํฐ๋ฏธ๋์ ์ก์ธ์คํ ์ ์์ต๋๋ค.
- ์ผ์ชฝ ์ฐฝ์ Notebooks(๋ ธํธ๋ถ) ์น์ ์ผ๋ก ์ด๋ํฉ๋๋ค.
- ์๋จ ๋๋กญ๋ค์ด ๋ฉ๋ด์์ ์ปดํจํ ์ธ์คํด์ค๋ฅผ ์ฐพ์ต๋๋ค.
- ํ์ผ ๋ธ๋ผ์ฐ์ ์๋์ ์๋ Terminal(ํฐ๋ฏธ๋) ์ต์ ์ ํด๋ฆญํ์ฌ ์ธ์คํด์ค์ ๋ํ ๋ช ๋ น์ค ์ธํฐํ์ด์ค๋ฅผ ์ฝ๋๋ค.

Link to this sectionYOLOv5 ์ค์ ๋ฐ ์คํ#
์ด์ ํ๊ฒฝ์ ์ค์ ํ๊ณ Ultralytics YOLOv5๋ฅผ ์คํํด ๋ณด๊ฒ ์ต๋๋ค.
Link to this section๊ฐ์ ํ๊ฒฝ ์์ฑ#
์ข ์์ฑ์ ๊ด๋ฆฌํ๊ธฐ ์ํด ๊ฐ์ ํ๊ฒฝ์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค. AzureML ์ปดํจํ ์ธ์คํด์ค์ ์ฌ์ ์ค์น๋ Conda๋ฅผ ์ฌ์ฉํ๊ฒ ์ต๋๋ค. ์์ธํ Conda ์ค์ ๊ฐ์ด๋๋ Ultralytics Conda ํต์คํํธ ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
ํน์ Python ๋ฒ์ ์ผ๋ก Conda ํ๊ฒฝ(์: yolov5env)์ ์์ฑํ๊ณ ํ์ฑํํฉ๋๋ค:
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 installedLink to this sectionYOLOv5 ์ ์ฅ์ ๋ณต์ #
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 --recursiveLink to this section์ข ์์ฑ ์ค์น#
requirements.txt ํ์ผ์ ๋์ด๋ ํ์ํ Python ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค. ๋ํ ๋ชจ๋ธ ๋ด๋ณด๋ด๊ธฐ ๊ธฐ๋ฅ์ ์ํด ONNX๋ ์ค์นํฉ๋๋ค.
pip install -r requirements.txt # Install core dependencies
pip install "onnx>=1.12.0" # Install ONNX for exportingLink to this sectionYOLOv5 ์์ ์ํ#
์ค์ ์ด ์๋ฃ๋๋ฉด ์ด์ YOLOv5 ๋ชจ๋ธ์ ํ์ต, ๊ฒ์ฆ, ์ถ๋ก ๋ฐ ๋ด๋ณด๋ด๊ธฐํ ์ ์์ต๋๋ค.
-
COCO128์ ๊ฐ์ ๋ฐ์ดํฐ์ ์ผ๋ก ๋ชจ๋ธ์ **ํ์ต(Train)**ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ํ์ต ๋ชจ๋ ๋ฌธ์๋ฅผ ํ์ธํ์ญ์์ค.
# 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 -
Precision, Recall, mAP์ ๊ฐ์ ์งํ๋ฅผ ์ฌ์ฉํ์ฌ ํ์ต๋ ๋ชจ๋ธ์ ์ฑ๋ฅ์ **๊ฒ์ฆ(Validate)**ํฉ๋๋ค. ์ต์ ์ ๊ฒ์ฆ ๋ชจ๋ ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
# Validate the yolov5s model on the COCO128 validation set python val.py --weights yolov5s.pt --data coco128.yaml --img 640 -
์ ์ด๋ฏธ์ง๋ ๋์์์ ๋ํด **์ถ๋ก (Run Inference)**์ ์คํํฉ๋๋ค. ๋ค์ํ ์ถ๋ก ์์ค์ ๋ํ ๋ด์ฉ์ ์์ธก ๋ชจ๋ ๋ฌธ์๋ฅผ ์ดํด๋ณด์ญ์์ค.
# Run inference with yolov5s on sample images python detect.py --weights yolov5s.pt --source data/images --img 640 -
๋ฐฐํฌ๋ฅผ ์ํด ๋ชจ๋ธ์ ONNX, TensorRT ๋๋ CoreML๊ณผ ๊ฐ์ ๋ค์ํ ํ์์ผ๋ก **๋ด๋ณด๋ด๊ธฐ(Export)**ํฉ๋๋ค. ๋ด๋ณด๋ด๊ธฐ ๋ชจ๋ ๊ฐ์ด๋์ ONNX ํตํฉ ํ์ด์ง๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
# Export yolov5s to ONNX format python export.py --weights yolov5s.pt --include onnx --img 640
Link to this section๋ ธํธ๋ถ ์ฌ์ฉ#
๋ํํ ํ๊ฒฝ์ ์ ํธํ๋ ๊ฒฝ์ฐ AzureML ๋ ธํธ๋ถ ๋ด์์ ์ด ๋ช ๋ น๋ค์ ์คํํ ์ ์์ต๋๋ค. Conda ํ๊ฒฝ์ ์ฐ๊ฒฐ๋ ์ฌ์ฉ์ ์ง์ IPython ์ปค๋์ ์์ฑํด์ผ ํฉ๋๋ค.
Link to this section์ IPython ์ปค๋ ์์ฑ#
์ปดํจํ ์ธ์คํด์ค ํฐ๋ฏธ๋์์ ๋ค์ ๋ช ๋ น์ ์คํํฉ๋๋ค:
# 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)"์ปค๋์ ์์ฑํ ํ ๋ธ๋ผ์ฐ์ ๋ฅผ ์๋ก ๊ณ ์นจํฉ๋๋ค. .ipynb ๋
ธํธ๋ถ ํ์ผ์ ์ด๊ฑฐ๋ ์์ฑํ ๋, ์ค๋ฅธ์ชฝ ์๋จ์ ์ปค๋ ๋๋กญ๋ค์ด ๋ฉ๋ด์์ ์ ์ปค๋("Python (yolov5env)")์ ์ ํํ์ญ์์ค.
Link to this section๋ ธํธ๋ถ ์ ์์ ๋ช ๋ น ์คํ#
-
Python ์ : Python ์ ์ ์ฝ๋๋ ์ ํํ
yolov5env์ปค๋์ ์ฌ์ฉํ์ฌ ์๋์ผ๋ก ์คํ๋ฉ๋๋ค. -
Bash ์ : ์ ธ ๋ช ๋ น์ ์คํํ๋ ค๋ฉด ์ ์์ ๋ถ๋ถ์
%%bash๋งค์ง ๋ช ๋ น์ ์ฌ์ฉํ์ญ์์ค. ๊ฐ bash ์ ์ ๋ ธํธ๋ถ ์ปค๋ ํ๊ฒฝ ์ปจํ ์คํธ๋ฅผ ์๋์ผ๋ก ์์ํ์ง ์์ผ๋ฏ๋ก ๊ฐ ์ ๋ด์์ Conda ํ๊ฒฝ์ ํ์ฑํํด์ผ ํฉ๋๋ค.%%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
์ถํํฉ๋๋ค! AzureML์์ Ultralytics YOLOv5๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ์ค์ ํ๊ณ ์คํํ์ต๋๋ค. ์ถ๊ฐ ํ์ต์ ์ํด ๋ค๋ฅธ Ultralytics ํตํฉ ๋๋ ์์ธํ YOLOv5 ๋ฌธ์๋ฅผ ํ์ธํด ๋ณด์ญ์์ค. ๋ถ์ฐ ํ์ต์ด๋ ์๋ํฌ์ธํธ๋ก์์ ๋ชจ๋ธ ๋ฐฐํฌ์ ๊ฐ์ ๊ณ ๊ธ ์๋๋ฆฌ์ค์ ๊ฒฝ์ฐ AzureML ๋ฌธ์๋ ์ ์ฉํ ๊ฒ์ ๋๋ค.