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

MLflow ํ†ตํ•ฉ ๋Œ€์ƒ Ultralytics YOLO

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

์†Œ๊ฐœ

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

์ด ๋ฌธ์„œ ํŽ˜์ด์ง€๋Š” 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.

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

    export MLFLOW_RUN=<your_run_name>
    

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

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

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

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

  4. 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 ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.



Created 2023-11-12, Updated 2024-06-10
Authors: glenn-jocher (6), Burhan-Q (1)

๋Œ“๊ธ€