ClearML çµ±å
ã«ã€ããŠClearML
ClearMLã¯ãâ±ïžãããªãã®æéãç¯çŽããããã«èšèšããããªãŒãã³ãœãŒã¹ã®ããŒã«ããã¯ã¹ã§ãã
ðšYOLOv5 ãå®éšãããŒãžã£ãŒã§ãã¹ãŠã®ãã¬ãŒãã³ã°å®è¡ã远跡ããã
ð§ çµ±åãããClearML ããŒã¿ã»ããŒãžã§ãã³ã°ã»ããŒã«ã§ãã«ã¹ã¿ã ã»ãã¬ãŒãã³ã°ã»ããŒã¿ãããŒãžã§ã³ã¢ããããç°¡åã«ã¢ã¯ã»ã¹ã§ããŸãã
ðŠClearML ãšãŒãžã§ã³ãã䜿çšããŠãYOLOv5 ãã¬ãŒãã³ã°ããªã¢ãŒãã§å®æœããã¢ãã¿ãªã³ã°ããŸãã
á¬ClearML ãã€ããŒãã©ã¡ãŒã¿æé©åã䜿çšããŠãæè¯ã® mAP ãåŸãã
âªSo_1F52D âªSo_1F52D âªSo_1F52D ðClearML Serving ã䜿ã£ãŠãããããªã³ãã³ãã§æ°ããåŠç¿ããYOLOv5 ã¢ãã«ã API ã«å€æããã
ä»ã«ãããããããããããã®ããŒã«ãããã€äœ¿ããã¯ããªã次第ã§ãå®éšãããŒãžã£ãŒã ãã«ãã ããããšãã§ãããããã¹ãŠãé£éãããŠå°è±¡çãªãã€ãã©ã€ã³ã«ããããšãã§ããïŒ
ðŠŸ ã»ããã£ã³ã°ããã
å®éšãããŒã¿ãèšé²ããããã«ãClearML ã¯ãµãŒããŒãšéä¿¡ããå¿ èŠããããŸãããµãŒããŒãæã«å ¥ããã«ã¯2ã€ã®æ¹æ³ãããïŒ
ClearML ãã¹ãã£ã³ã°ã»ãµãŒãã¹ã«ç¡æã§ãµã€ã³ã¢ãããããããŸãã¯èªåã®ãµãŒããŒãç«ã¡äžããããšãã§ããŸãããµãŒããŒããããªãŒãã³ãœãŒã¹ãªã®ã§ãæ©å¯ããŒã¿ãæ±ã£ãŠããŠãåé¡ãªãã¯ãã ïŒ
-
ãã€ã³ã¹ããŒã«ããŸãã
clearml
python ããã±ãŒãžã§æäŸãããïŒ -
ClearML SDKããµãŒããŒã«æ¥ç¶ããã«ã¯ãèªèšŒæ å ±ãäœæãïŒå³äžã®ãèšå®ãâãã¯ãŒã¯ã¹ããŒã¹ãâãæ°ããèªèšŒæ å ±ãäœæãïŒã以äžã®ã³ãã³ããå®è¡ããæ瀺ã«åŸã£ãŠãã ããïŒ
以äžã§ãïŒå®äºã§ãðã
ð ãã¬ãŒãã³ã°YOLOv5 WithClearML
ClearML å®éšè¿œè·¡ãæå¹ã«ããã«ã¯ãClearML pip ããã±ãŒãžãã€ã³ã¹ããŒã«ããã ãã§ããã
ããã«ãããYOLOv5 ãã¬ãŒãã³ã°ã¹ã¯ãªãããšã®çµ±åãå¯èœã«ãªããä»åŸããã¹ãŠã®ãã¬ãŒãã³ã°å®è¡ã¯ClearML experiment managerã«åã蟌ãŸããä¿åãããã
ãå€æŽãããå Žå project_name
ãŸã㯠task_name
ã䜿çšããã --project
ãã㊠--name
ã®åŒæ°ã§ããã train.py
ã¹ã¯ãªããã䜿çšããå Žåãããã©ã«ãã§ã¯ãããžã§ã¯ã㯠YOLOv5
ãã㊠Training
.泚æïŒClearML /
ããµããããžã§ã¯ãã®åºåãæåãšããŠäœ¿ãå Žåã¯æ³šæãå¿
èŠã§ãã /
ããããžã§ã¯ãåã«å
¥ããŠãã ããïŒ
ãŸãã¯ã«ã¹ã¿ã ãããžã§ã¯ãåãšã«ã¹ã¿ã ã¿ã¹ã¯åãæå®ããïŒ
python train.py --project my_project --name my_training --img 640 --batch 16 --epochs 3 --data coco8.yaml --weights yolov5s.pt --cache
ããã¯æç²ããïŒ
- ãœãŒã¹ã³ãŒãïŒæªã³ãããã®å€æŽ
- ã€ã³ã¹ããŒã«ãããŠããããã±ãŒãž
- (ãã€ããŒïŒãã©ã¡ãŒã¿ãŒ
- ã¢ãã«ãã¡ã€ã«
--save-period n
nãšããã¯ããšã«ãã§ãã¯ãã€ã³ããä¿åãã) - ã³ã³ãœãŒã«åºå
- ã¹ã«ã©ãŒïŒmAP_0.5ãmAP_0.5:0.95ã粟床ãåçŸçãæ倱ãåŠç¿çã...ïŒ
- ãã·ã³ã®è©³çŽ°ãã©ã³ã¿ã€ã ãäœææ¥ãªã©ã®äžè¬çãªæ å ±ã
- ã©ãã«çžé¢å³ãæ··åè¡åãªã©ãçæããããã¹ãŠã®ãããã
- ãšããã¯ããšã®ããŠã³ãã£ã³ã°ããã¯ã¹ä»ãç»å
- ãšããã¯ããšã®ã¢ã¶ã€ã¯
- ãšããã¯ããšã®æ€èšŒç»å
ãããéã§ãããïŒã§ã¯ããããã®æ å ±ãClearML UIã§å¯èŠåãããã¬ãŒãã³ã°ã®é²æç¶æ³ãææ¡ããŸããããããŒãã«ãã¥ãŒã«ã«ã¹ã¿ã ã«ã©ã ïŒäŸãã°mAP_0.5ãªã©ïŒãè¿œå ããããšã§ãæãããã©ãŒãã³ã¹ã®é«ãã¢ãã«ãç°¡åã«ãœãŒãããããšãã§ããŸãããŸããè€æ°ã®å®éšãéžæããŠçŽæ¥æ¯èŒããããšãã§ããŸãïŒ
ãã€ããŒãã©ã¡ãŒã¿ãŒã®æé©åããªã¢ãŒãå®è¡ãªã©ããããã®æ å ±ã䜿ã£ãŠã§ããããšã¯ãŸã ãŸã ããïŒ
ð ããŒã¿ã»ããã®ããŒãžã§ã³ç®¡ç
ããŒã¿ãã³ãŒããšã¯å¥ã«ããŒãžã§ã³ç®¡çããããšã¯ãäžè¬çã«è¯ãã¢ã€ãã¢ã§ãããã®ãªããžããªã¯ããŒã¿ã»ããã®ããŒãžã§ã³IDã®å ¥åããµããŒãããŠããŸããããã«ããã®ã¯ãŒã¯ãããŒã§ã¯äœ¿çšããããŒã¿ã»ããIDãã¿ã¹ã¯ãã©ã¡ãŒã¿ãŒã®äžéšãšããŠä¿åããã®ã§ãã©ã®å®éšã«ã©ã®ããŒã¿ã䜿ãããããåžžã«ç¢ºå®ã«ç¥ãããšãã§ããïŒ
ããŒã¿ã»ãããæºåãã
YOLOv5 ãªããžããªã¯ãããŒã¿ã»ããã®æ
å ±ãå«ã YAML ãã¡ã€ã«ã䜿çšããããšã§ãããŸããŸãªããŒã¿ã»ããããµããŒãããŠããŸããããã©ã«ãã§ã¯ãããŒã¿ã»ãã㯠../datasets
ãã©ã«ããŒããªããžããªã®ã«ãŒããã©ã«ããŒã«é¢é£ä»ããŸããã€ãŸã coco128
YAMLã®ãªã³ã¯ã䜿ãããyolov5 ãæäŸããã¹ã¯ãªããã䜿ããšããã®ãããªãã©ã«ãæ§é ã«ãªããŸãïŒ
ããããããã¯ã©ã®ãããªããŒã¿ã»ããã§ãæ§ããŸããããã®ãã©ã«ãæ§é ã«åŸã£ãŠããéãããèªç±ã«ã䜿ããã ããã
次ã«ãâ ïžã察å¿ããYAMLãã¡ã€ã«ãããŒã¿ã»ãããã©ã«ããŒã®ã«ãŒãâ ïžããã®YAMLãã¡ã€ã«ã«ã¯ãClearML ãããŒã¿ã»ãããé©åã«äœ¿ãããã«å¿ èŠãªæ å ±ãå«ãŸããŠããŸãããã¡ããããã®YAMLãã¡ã€ã«ãèªåã§äœãããšãã§ããŸãã
åºæ¬çã«ã¯ä»¥äžã®ããŒãå¿
èŠã ïŒ path
, train
, test
, val
, nc
, names
.
..
|_ yolov5
|_ datasets
|_ coco128
|_ images
|_ labels
|_ coco128.yaml # <---- HERE!
|_ LICENSE
|_ README.txt
ããŒã¿ã»ãããã¢ããããŒããã
ãã®ããŒã¿ã»ãããããŒãžã§ã³ç®¡çãããããŒã¿ã»ãããšããŠClearML ã«åã蟌ãã«ã¯ãããŒã¿ã»ããã®ã«ãŒãã»ãã©ã«ããŒã«ç§»åããŠã次ã®ã³ãã³ããå®è¡ããïŒ
ã³ãã³ã clearml-data sync
ã¯å®éã«ã¯çç¥ã³ãã³ãã§ããããããã®ã³ãã³ãã次ã
ã«å®è¡ããããšãã§ããïŒ
# Optionally add --parent <parent_dataset_id> if you want to base
# this version on another dataset version, so no duplicate files are uploaded!
clearml-data create --name coco128 --project YOLOv5
clearml-data add --files .
clearml-data close
ClearML ããŒã¿ã»ããã䜿ã£ããã¬ãŒãã³ã°ã®å®è¡
ããã§ãClearML ããŒã¿ã»ãããæã«å ¥ã£ãã®ã§ãããã䜿ã£ãŠã«ã¹ã¿ã YOLOv5 ðã¢ãã«ãèšç·Žããããšãéåžžã«ç°¡åã«ã§ããïŒ
python train.py --img 640 --batch 16 --epochs 3 --data clearml://<your_dataset_id> --weights yolov5s.pt --cache
ãã€ããŒãã©ã¡ãŒã¿ã®æé©å
å®éšãšããŒã¿ã®ããŒãžã§ã³ç®¡çãã§ããã®ã§ã次ã¯ãã®äžã«äœãæ§ç¯ããããèŠãŠã¿ããïŒ
ã³ãŒãæ å ±ãã€ã³ã¹ããŒã«ãããããã±ãŒãžãç°å¢ã®è©³çŽ°ã䜿ã£ãŠãå®éšãã®ãã®ãå®å šã«åçŸã§ããããã«ãªã£ããå®éãClearML ãå®éšãã¯ããŒã³ãããã®ãã©ã¡ãŒã¿ãŒãå€æŽããããšãã§ãããããããã°ãèªåçã«æ°ãããã©ã¡ãŒã¿ãŒã§å®éšãåå®è¡ããããšãã§ããïŒ
ãã€ããŒãã©ã¡ãŒã¿ã®æé©åãããŒã«ã«ã§å®è¡ããããã«ãäºåã«äœæããã¹ã¯ãªãããçšæããŸããããã¬ãŒãã³ã°ã¿ã¹ã¯ãå°ãªããšãäžåºŠå®è¡ãããClearML experiment manager ã«ããããšã確èªããã ãã§ãåºæ¬çã«ãã®ã¿ã¹ã¯ãã¯ããŒã³ãããã€ããŒãã©ã¡ãŒã¿ãå€æŽããŸãã
ãã®IDãèšå
¥ããå¿
èŠãããã template task
ã«ããã¹ã¯ãªããã® utils/loggers/clearml/hpo.py
ã§ãå®è¡ããã ãã§ã :)ããªã㯠task.execute_locally()
ãžã® task.execute()
ã䜿ã£ãŠãClearML ãã¥ãŒã«å
¥ãã代ããã«ãªã¢ãŒããšãŒãžã§ã³ãã«äœæ¥ãããããšãã§ããã
# To use optuna, install it first, otherwise you can change the optimizer to just be RandomSearch
pip install optuna
python utils/loggers/clearml/hpo.py
ãªã¢ãŒãå®è¡ (äžçŽ)
HPOãããŒã«ã«ã§å®è¡ããã®ã¯ãšãŠã䟿å©ã§ããã代ããã«ãªã¢ãŒããã·ã³ã§å®éšãå®è¡ãããå Žåã¯ã©ããããããã§ããããïŒéåžžã«ãã¯ãã«ãªGPU ãã·ã³ããªã³ãµã€ãã§å©çšã§ãããããããªãããã¯ã©ãŠãGPUã䜿ãäºç®ããããããããªããããã§ãClearML ãšãŒãžã§ã³ãã®åºçªã ããšãŒãžã§ã³ããã§ããããšãããã§ãã§ãã¯ããŠãã ããïŒ
èŠããã«ããšã¯ã¹ããªã¡ã³ããããŒãžã£ãŒã远跡ããŠããå šãŠã®å®éšã«ã¯ããããå¥ã®ãã·ã³ã§åçŸããã®ã«ååãªæ å ±ãå«ãŸããŠããïŒã€ã³ã¹ããŒã«ãããŠããããã±ãŒãžãã³ããããããŠããªãå€æŽãªã©ïŒãã€ãŸããClearML ãšãŒãžã§ã³ãã¯ãåä¿¡ã¿ã¹ã¯ã®ãã¥ãŒããªãã¹ã³ããã¿ã¹ã¯ãèŠã€ãããšç°å¢ãåäœæããŠå®è¡ããåæã«ã¹ã«ã©ãŒããããããªã©ããšã¯ã¹ããªã¡ã³ããããŒãžã£ãŒã«å ±åããã
ã©ã®ãããªãã·ã³ïŒã¯ã©ãŠãVMãããŒã«ã«ã®GPU ãã·ã³ãèªåã®ã©ããããã...ïŒã§ããå®è¡ããã ãã§ClearML ãšãŒãžã§ã³ãã«å€ããããšãã§ããïŒ
ã¯ããŒã³ãç·šéããšã³ãã¥ãŒ
ãšãŒãžã§ã³ããå®è¡ãããã®ã§ãå°ãä»äºããããããšãã§ãããHPOã®ã»ã¯ã·ã§ã³ã§ãã¿ã¹ã¯ãã¯ããŒã³ããŠãã€ããŒãã©ã¡ãŒã¿ãç·šéã§ããããšãèŠããŠããã ãããïŒã€ã³ã¿ãŒãã§ã€ã¹ããããããã§ããïŒ
å³ã¯ãªãã¯ããŠå®éšãã¯ããŒã³ããã
ãã€ããŒãã©ã¡ãŒã¿ãç·šéããã
ã¿ã¹ã¯ãå³ã¯ãªãã¯ããŠãããããã®ãã¥ãŒã«ãšã³ãã¥ãŒããã
ãªã¢ãŒãã§ã®ã¿ã¹ã¯å®è¡
äžèšã§èª¬æããããã«ãã¿ã¹ã¯ãã¯ããŒã³ããããšãã§ããŸãã task.execute_remotely()
å®è¡ããããšããšãŒãžã§ã³ããäœæ¥ãéå§ããããã®ãã¥ãŒã«å
¥ããããïŒ
YOLOv5 ãã¬ãŒãã³ã°ã¹ã¯ãªããããªã¢ãŒãã§å®è¡ããã«ã¯ãclearml ãã¬ãŒãã€ã³ã¹ã¿ã³ã¹åãããåŸãtraining.py ã¹ã¯ãªããã«æ¬¡ã®è¡ãè¿œå ããã ãã§ãïŒ
# ...
# Loggers
data_dict = None
if RANK in {-1, 0}:
loggers = Loggers(save_dir, weights, opt, hyp, LOGGER) # loggers instance
if loggers.clearml:
loggers.clearml.task.execute_remotely(queue="my_queue") # <------ ADD THIS LINE
# Data_dict is either None is user did not choose for ClearML dataset or is filled in by ClearML
data_dict = loggers.clearml.data_dict
# ...
ãã®å€æŽåŸã«ãã¬ãŒãã³ã°ã¹ã¯ãªãããå®è¡ãããšãpython ããã®è¡ãŸã§ã¯ã¹ã¯ãªãããå®è¡ããããã以éã¯ã³ãŒããããã±ãŒãžåããŠãã¥ãŒã«éä¿¡ããŸãïŒ
ãªãŒãã¹ã±ãŒãªã³ã°ã¯ãŒã«ãŒ
ClearML ãªãŒãã¹ã±ãŒã©ãä»å±ããŠããŸãïŒãã®ããŒã«ã¯ãéžæããã¯ã©ãŠãïŒAWSãGCPãAzureïŒã«æ°ãããªã¢ãŒããã·ã³ãèªåçã«ã¹ãã³ã¢ãããããã¥ãŒã«å®éšãæ€åºããããã³ã«ãããããClearML ãšãŒãžã§ã³ãã«å€ããŸããã¿ã¹ã¯ãåŠçããããšããªãŒãã¹ã±ãŒã©ã¯èªåçã«ãªã¢ãŒããã·ã³ãã·ã£ããããŠã³ããããªãã¯æ¯æããåæ¢ããïŒ
ãªãŒãã¹ã±ãŒã©ãŒã®ã¹ã¿ãŒãã»ãããªãã芧ãã ããã