์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

๋‹ค์Œ์„ ์œ„ํ•œ MLflow ํ†ตํ•ฉ Ultralytics YOLO

MLflow ์—์ฝ”์‹œ์Šคํ…œ

์†Œ๊ฐœ

์‹คํ—˜ ๋กœ๊น…์€ ๋‹ค์–‘ํ•œ ๋ฉ”ํŠธ๋ฆญ, ๋งค๊ฐœ๋ณ€์ˆ˜, ์•„ํ‹ฐํŒฉํŠธ๋ฅผ ์ถ”์ ํ•  ์ˆ˜ ์žˆ๋Š” ๋จธ์‹  ๋Ÿฌ๋‹ ์›Œํฌํ”Œ๋กœ์šฐ์˜ ์ค‘์š”ํ•œ ์ธก๋ฉด์ž…๋‹ˆ๋‹ค. ๋ชจ๋ธ ์žฌํ˜„์„ฑ์„ ๋†’์ด๊ณ , ๋ฌธ์ œ๋ฅผ ๋””๋ฒ„๊ทธํ•˜๊ณ , ๋ชจ๋ธ ์„ฑ๋Šฅ์„ ๊ฐœ์„ ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค. Ultralytics YOLO, known for its real-time object detection capabilities, now offers integration with MLflow, an open-source platform for complete machine learning lifecycle management.

์ด ๋ฌธ์„œ ํŽ˜์ด์ง€๋Š” Ultralytics YOLO ํ”„๋กœ์ ํŠธ์˜ MLflow ๋กœ๊น… ๊ธฐ๋Šฅ์„ ์„ค์ •ํ•˜๊ณ  ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ข…ํ•ฉ์ ์ธ ์•ˆ๋‚ด์„œ์ž…๋‹ˆ๋‹ค.

MLflow๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

MLflow๋Š” ์—”๋“œํˆฌ์—”๋“œ ๋จธ์‹  ๋Ÿฌ๋‹ ์ˆ˜๋ช… ์ฃผ๊ธฐ๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋ฐ์ดํ„ฐ๋ธŒ๋ฆญ์Šค์—์„œ ๊ฐœ๋ฐœํ•œ ์˜คํ”ˆ ์†Œ์Šค ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ์‹คํ—˜ ์ถ”์ , ์žฌํ˜„ ๊ฐ€๋Šฅํ•œ ์‹คํ–‰์œผ๋กœ ์ฝ”๋“œ ํŒจํ‚ค์ง•, ๋ชจ๋ธ ๊ณต์œ  ๋ฐ ๋ฐฐํฌ๋ฅผ ์œ„ํ•œ ๋„๊ตฌ๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. MLflow๋Š” ๋ชจ๋“  ๋จธ์‹  ๋Ÿฌ๋‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์™€ ํ•จ๊ป˜ ์ž‘๋™ํ•˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

ํŠน์ง•

  • ๋ฉ”ํŠธ๋ฆญ ๋กœ๊น…: ๊ฐ ์—ํฌํฌ๊ฐ€ ๋๋‚  ๋•Œ์™€ ๊ต์œก์ด ๋๋‚  ๋•Œ ๋ฉ”ํŠธ๋ฆญ์„ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค.
  • ํŒŒ๋ผ๋ฏธํ„ฐ ๋กœ๊น…: ํŠธ๋ ˆ์ด๋‹์— ์‚ฌ์šฉ๋œ ๋ชจ๋“  ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค.
  • ์•„ํ‹ฐํŒฉํŠธ ๋กœ๊น…: ํ•™์Šต์ด ๋๋‚  ๋•Œ ๊ฐ€์ค‘์น˜ ๋ฐ ๊ตฌ์„ฑ ํŒŒ์ผ์„ ํฌํ•จํ•œ ๋ชจ๋ธ ์•„ํ‹ฐํŒฉํŠธ๋ฅผ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค.

์„ค์ • ๋ฐ ์‚ฌ์ „ ์š”๊ตฌ ์‚ฌํ•ญ

MLflow๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ pip๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค:

pip install mlflow

Ultralytics ์„ค์ •์—์„œ MLflow ๋กœ๊น…์ด ํ™œ์„ฑํ™”๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ์ด ์„ค์ •์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์„ค์ •์œผ๋กœ ์ œ์–ด๋ฉ๋‹ˆ๋‹ค. mflow ํ‚ค๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ์ฐธ์กฐ ์„ค์ • ํŽ˜์ด์ง€์—์„œ ์ž์„ธํ•œ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

์—…๋ฐ์ดํŠธ Ultralytics MLflow ์„ค์ •

Python ํ™˜๊ฒฝ ๋‚ด์—์„œ update ๋ฉ”์„œ๋“œ์˜ settings ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์ •์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

from ultralytics import settings

# Update a setting
settings.update({'mlflow': True})

# Reset settings to default values
settings.reset()

๋ช…๋ น์ค„ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์ •์„ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

# Update a setting
yolo settings runs_dir='/path/to/runs'

# Reset settings to default values
yolo settings reset

์‚ฌ์šฉ ๋ฐฉ๋ฒ•

๋ช…๋ น์–ด

  1. ํ”„๋กœ์ ํŠธ ์ด๋ฆ„์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค: ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ํ”„๋กœ์ ํŠธ ์ด๋ฆ„์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

    export MLFLOW_EXPERIMENT_NAME=<your_experiment_name>
    

๋˜๋Š” project=<project> ์ธ์ˆ˜, ์ฆ‰ YOLO ๋ชจ๋ธ์„ ํ›ˆ๋ จํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. yolo train project=my_project.

  1. ์‹คํ–‰ ์ด๋ฆ„ ์„ค์ •: ํ”„๋กœ์ ํŠธ ์ด๋ฆ„ ์„ค์ •๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ์‹คํ–‰ ์ด๋ฆ„์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

    export MLFLOW_RUN=<your_run_name>
    

๋˜๋Š” name=<name> ์ธ์ˆ˜, ์ฆ‰ YOLO ๋ชจ๋ธ์„ ํ›ˆ๋ จํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. yolo train project=my_project name=my_name.

  1. ๋กœ์ปฌ MLflow ์„œ๋ฒ„๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค: ์ถ”์ ์„ ์‹œ์ž‘ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค:

    mlflow server --backend-store-uri runs/mlflow'
    

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ http://127.0.0.1:5000 ์—์„œ ๋กœ์ปฌ ์„œ๋ฒ„๊ฐ€ ์‹œ์ž‘๋˜๊ณ  ๋ชจ๋“  mlflow ๋กœ๊ทธ๊ฐ€ 'runs/mlflow' ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ URI๋ฅผ ์ง€์ •ํ•˜๋ ค๋ฉด MLFLOW_TRACKING_URI ํ™˜๊ฒฝ ๋ณ€์ˆ˜์ž…๋‹ˆ๋‹ค.

  1. MLflow ์„œ๋ฒ„ ์ธ์Šคํ„ด์Šค ์ข…๋ฃŒ: ์‹คํ–‰ ์ค‘์ธ ๋ชจ๋“  MLflow ์ธ์Šคํ„ด์Šค๋ฅผ ์ค‘์ง€ํ•˜๋ ค๋ฉด ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

    ps aux | grep 'mlflow' | grep -v 'grep' | awk '{print $2}' | xargs kill -9
    

๋กœ๊น…

๋กœ๊น…์€ on_pretrain_routine_end, on_fit_epoch_end๋ฐ on_train_end ์ฝœ๋ฐฑ ํ•จ์ˆ˜. ์ด๋Ÿฌํ•œ ํ•จ์ˆ˜๋Š” ํ•™์Šต ํ”„๋กœ์„ธ์Šค์˜ ๊ฐ ๋‹จ๊ณ„์—์„œ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ๋˜๋ฉฐ ๋งค๊ฐœ๋ณ€์ˆ˜, ์ง€ํ‘œ ๋ฐ ์•„ํ‹ฐํŒฉํŠธ์˜ ๋กœ๊น…์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ์ œ

  1. ์‚ฌ์šฉ์ž ์ง€์ • ์ง€ํ‘œ ๋กœ๊น…: ์‚ฌ์šฉ์ž ์ •์˜ ๋ฉ”ํŠธ๋ฆญ์„ ์ˆ˜์ •ํ•˜์—ฌ ๊ธฐ๋กํ•  ์‚ฌ์šฉ์ž ์ •์˜ ๋ฉ”ํŠธ๋ฆญ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. trainer.metrics ์‚ฌ์ „ ์ด์ „ on_fit_epoch_end ๊ฐ€ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

  2. ์‹คํ—˜ ๋ณด๊ธฐ: ๋กœ๊ทธ๋ฅผ ๋ณด๋ ค๋ฉด MLflow ์„œ๋ฒ„(์ผ๋ฐ˜์ ์œผ๋กœ http://127.0.0.1:5000)๋กœ ์ด๋™ํ•˜์—ฌ ์‹คํ—˜์„ ์„ ํƒํ•˜๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. YOLO MLflow ์‹คํ—˜

  3. ์‹คํ–‰ ๋ณด๊ธฐ: ๋Ÿฐ์€ ์‹คํ—˜ ๋‚ด์˜ ๊ฐœ๋ณ„ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค. ๋Ÿฐ์„ ํด๋ฆญํ•˜๋ฉด ์—…๋กœ๋“œ๋œ ์•„ํ‹ฐํŒฉํŠธ ๋ฐ ๋ชจ๋ธ ๊ฐ€์ค‘์น˜๋ฅผ ํฌํ•จํ•œ ๋Ÿฐ ์„ธ๋ถ€ ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. YOLO MLflow ์‹คํ–‰

MLflow ๋น„ํ™œ์„ฑํ™”

MLflow ๋กœ๊น…์„ ๋„๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•˜์„ธ์š”:

yolo settings mlflow=False

๊ฒฐ๋ก 

๋จธ์‹  ๋Ÿฌ๋‹ ์‹คํ—˜์„ ์ถ”์ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ„์†Œํ™”๋œ ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜๋Š” MLflow ๋กœ๊น… ํ†ตํ•ฉ( Ultralytics YOLO ). ์ด๋ฅผ ํ†ตํ•ด ์„ฑ๋Šฅ ์ง€ํ‘œ๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ์•„ํ‹ฐํŒฉํŠธ๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ๊ฐ•๋ ฅํ•œ ๋ชจ๋ธ ๊ฐœ๋ฐœ ๋ฐ ๋ฐฐํฌ์— ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ MLflow ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.



์ƒ์„ฑ๋จ 2023-11-12, ์—…๋ฐ์ดํŠธ๋จ 2024-01-07
์ž‘์„ฑ์ž: glenn-jocher (3)

๋Œ“๊ธ€