ã¬ã€ãã¥ãŒã³ãšãã€ããŒãã©ã¡ãŒã¿ã®å¹ççãªãã¥ãŒãã³ã° YOLO11
ãã€ããŒãã©ã¡ãŒã¿ã®ãã¥ãŒãã³ã°ã¯ãæé©ãªãã€ããŒãã©ã¡ãŒã¿ã®ã»ãããçºèŠããããšã«ãã£ãŠãã¢ãã«ã®æ§èœãæé«ã«ããããã«äžå¯æ¬ ã§ãããããã«ã¯ãç°ãªããã€ããŒãã©ã¡ãŒã¿ã§è©Šè¡ãå®è¡ããåè©Šè¡ã®ããã©ãŒãã³ã¹ãè©äŸ¡ããããšãå«ãŸããŸãã
Ultralytics YOLO11 ãšRay Tuneã§ãã¥ãŒãã³ã°ãå éããã
Ultralytics YOLO11Ray Tune ã¯ããã€ããŒãã©ã¡ãŒã¿ã®ãã¥ãŒãã³ã°ã®ããã« Ray Tune ãçµã¿èŸŒãã§ãããYOLO11 ã¢ãã«ã®ãã€ããŒãã©ã¡ãŒã¿ã®æé©åãå¹çåããŸããRay Tuneã䜿çšãããšãé«åºŠãªæ€çŽ¢ã¹ãã©ããžãŒã䞊ååŠçãæ©æåæ¢ãå©çšããŠããã¥ãŒãã³ã°ããã»ã¹ãè¿ éåããããšãã§ããŸãã
ã¬ã€ã»ãã¥ãŒã³
Ray Tuneã¯ãå¹çæ§ãšæè»æ§ã®ããã«èšèšããããã€ããŒãã©ã¡ãŒã¿ãã¥ãŒãã³ã°ã©ã€ãã©ãªã§ããæ§ã ãªæ¢çŽ¢æŠç¥ã䞊åæ§ãæ©æåæ¢æŠç¥ããµããŒãããUltralytics YOLO11 ãå«ãäžè¬çãªæ©æ¢°åŠç¿ãã¬ãŒã ã¯ãŒã¯ãšã·ãŒã ã¬ã¹ã«çµ±åããŸãã
ãšã®çµ±åWeights & Biases
YOLO11 ãŸãããªãã·ã§ã³ã§ Weights & Biasesãšã®çµ±åãå¯èœã§ãã
ã€ã³ã¹ããŒã«
å¿ èŠãªããã±ãŒãžãã€ã³ã¹ããŒã«ããã«ã¯
ã€ã³ã¹ããŒã«
䜿çšæ¹æ³
䜿çšæ¹æ³
tune()
ã¡ãœããã»ãã©ã¡ãŒã¿
ã«ã€ã㊠tune()
YOLO11 ã¡ãœããã¯ãRay Tune ã«ãããã€ããŒãã©ã¡ãŒã¿ã®ãã¥ãŒãã³ã°ã®ããã®äœ¿ããããã€ã³ã¿ãŒãã§ã€ã¹ãæäŸããŸãããã¥ãŒãã³ã°ããã»ã¹ãã«ã¹ã¿ãã€ãºã§ããããã€ãã®åŒæ°ãåãåããŸãã以äžã¯åãã©ã¡ãŒã¿ã®è©³çŽ°ãªèª¬æã§ãïŒ
ãã©ã¡ãŒã¿ | ã¿ã€ã | 説æ | ããã©ã«ãå€ |
---|---|---|---|
data |
str |
ãã¥ãŒããŒãå®è¡ããããŒã¿ã»ããèšå®ãã¡ã€ã«ïŒYAML圢åŒïŒããã®ãã¡ã€ã«ã«ã¯ãåŠç¿ããŒã¿ãšæ€èšŒããŒã¿ã®ãã¹ãããã³ãã®ä»ã®ããŒã¿ã»ããåºæã®èšå®ãæå®ããŸãã | |
space |
dict, optional |
Ray Tune ã®ãã€ããŒãã©ã¡ãŒã¿æ¢çŽ¢ç©ºéãå®çŸ©ããèŸæžãåããŒã¯ãã€ããŒãã©ã¡ãŒã¿åã«å¯Ÿå¿ããå€ã¯ãã¥ãŒãã³ã°äžã«æ¢çŽ¢ããå€ã®ç¯å²ãæå®ããŸããæäŸãããªãå ŽåãYOLO11 ã¯ãããŸããŸãªãã€ããŒãã©ã¡ãŒã¿ãæã€ããã©ã«ãã®æ€çŽ¢ç©ºéã䜿çšããŸãã | |
grace_period |
int, optional |
Ray Tune ã«ãããASHA ã¹ã±ãžã¥ãŒã©ã®ç¶äºæéïŒãšããã¯ïŒãã¹ã±ãžã¥ãŒã©ã¯ãã®ãšããã¯æ°ããåã«ãã©ã€ã¢ã«ãçµäºããããšã¯ãªããã¢ãã«ãæ©æåæ¢ã決å®ããåã«æäœéã®åŠç¿ãè¡ãããšãã§ããŸãã | 10 |
gpu_per_trial |
int, optional |
ãã¥ãŒãã³ã°äžã«ãã©ã€ã¢ã«ããšã«å²ãåœãŠãGPUã®æ°ãããã¯ãç¹ã«ãã«ãGPU ç°å¢ã§ãGPU ã®äœ¿çšã管çããã®ã«åœ¹ç«ã¡ãŸããæå®ããªãå Žåããã¥ãŒããŒã¯å©çšå¯èœãªãã¹ãŠã® GPU ã䜿çšããŸãã | ãªã |
iterations |
int, optional |
ãã¥ãŒãã³ã°äžã«å®è¡ããè©Šè¡ã®æ倧æ°ããã®ãã©ã¡ãŒã¿ã¯ããã¹ãããããã€ããŒãã©ã¡ãŒã¿ã®çµã¿åããã®ç·æ°ãå¶åŸ¡ããã®ã«åœ¹ç«ã¡ããã¥ãŒãã³ã°ããã»ã¹ãç¡éã«å®è¡ãããªãããã«ããŸãã | 10 |
**train_args |
dict, optional |
ã«æž¡ãè¿œå åŒæ°ã train() ã¡ãœããã«æž¡ãããšãã§ããããããã®åŒæ°ã«ã¯ãåŠç¿ãšããã¯æ°ãªã©ã®èšå®ãå«ããããšãã§ããã ããããµã€ãºãªã©ããã¬ãŒãã³ã°ã«ç¹åããæ§æã«ãªã£ãŠããã |
{} |
ãããã®ãã©ã¡ãŒã¿ãã«ã¹ã¿ãã€ãºããããšã§ãç¹å®ã®ããŒãºãšå©çšå¯èœãªèšç®ãªãœãŒã¹ã«åãããŠããã€ããŒãã©ã¡ãŒã¿æé©åããã»ã¹ã埮調æŽããããšãã§ããŸãã
ããã©ã«ãã®æ€çŽ¢ã¹ããŒã¹
次ã®è¡šã¯ãYOLO11 with Ray Tune ã§ãã€ããŒãã©ã¡ãŒã¿ããã¥ãŒãã³ã°ããããã®ããã©ã«ãã®ãµãŒãã¹ããŒã¹ãã©ã¡ãŒã¿ã®äžèŠ§ã§ããåãã©ã¡ãŒã¿ã¯ tune.uniform()
.
ãã©ã¡ãŒã¿ | å€ã®ç¯å² | 説æ |
---|---|---|
lr0 |
tune.uniform(1e-5, 1e-1) |
åæåŠç¿ç |
lrf |
tune.uniform(0.01, 1.0) |
æçµåŠç¿çä¿æ° |
momentum |
tune.uniform(0.6, 0.98) |
å¢ã |
weight_decay |
tune.uniform(0.0, 0.001) |
äœéæžå° |
warmup_epochs |
tune.uniform(0.0, 5.0) |
ãŠã©ãŒã ã¢ããã»ãšãã㯠|
warmup_momentum |
tune.uniform(0.0, 0.95) |
ãŠã©ãŒã ã¢ããã®å¢ã |
box |
tune.uniform(0.02, 0.2) |
ããã¯ã¹ãã¹éé |
cls |
tune.uniform(0.2, 4.0) |
æžéã¯ã©ã¹ |
hsv_h |
tune.uniform(0.0, 0.1) |
è²çžå¢åŒ·ç¯å² |
hsv_s |
tune.uniform(0.0, 0.9) |
飜åå¢å€§ç¯å² |
hsv_v |
tune.uniform(0.0, 0.9) |
å€ïŒèŒåºŠïŒå¢åŒ·ç¯å² |
degrees |
tune.uniform(0.0, 45.0) |
å転å¢å€§ç¯å²ïŒåºŠïŒ |
translate |
tune.uniform(0.0, 0.9) |
翻蚳å¢åŒ·ç¯å² |
scale |
tune.uniform(0.0, 0.9) |
è£åŒ·ç¯å²ã®æ¡å€§ |
shear |
tune.uniform(0.0, 10.0) |
åªæå¢å€§ç¯å²ïŒåºŠïŒ |
perspective |
tune.uniform(0.0, 0.001) |
ããŒã¹ãã¯ãã£ãæ¡åŒµç¯å² |
flipud |
tune.uniform(0.0, 1.0) |
åçŽããªããå¢å 確ç |
fliplr |
tune.uniform(0.0, 1.0) |
æ°Žå¹³ããªããå¢å 確ç |
mosaic |
tune.uniform(0.0, 1.0) |
ã¢ã¶ã€ã¯è£åŒ·ç¢ºç |
mixup |
tune.uniform(0.0, 1.0) |
æ··åè£åŒ·ç¢ºç |
copy_paste |
tune.uniform(0.0, 1.0) |
ã³ããè£åŒ·ç¢ºç |
ã«ã¹ã¿ã æ€çŽ¢ã¹ããŒã¹ã®äŸ
ãã®äŸã§ã¯ãRay Tune ãšYOLO11 ã䜿ã£ãŠããã€ããŒãã©ã¡ãŒã¿ã®ãã¥ãŒãã³ã°ã«ã«ã¹ã¿ã æ¢çŽ¢ç©ºéã䜿çšããæ¹æ³ã瀺ããŸããã«ã¹ã¿ã æ€çŽ¢ç©ºéãæäŸããããšã§ãé¢å¿ã®ããç¹å®ã®ãã€ããŒãã©ã¡ãŒã¿ã«ãã¥ãŒãã³ã°ããã»ã¹ãéäžãããããšãã§ããŸãã
䜿çšæ¹æ³
äžã®ã³ãŒãã»ã¹ããããã§ã¯ã"yolo11n.pt" ã®äºååŠç¿ãããéã¿ã§YOLO ã¢ãã«ãäœæããŸãããã㊠tune()
ã¡ãœããã§ãããŒã¿ã»ããã®èšå®ã "coco8.yaml "ã§æå®ãããåæåŠç¿çã®ããã®ã«ã¹ã¿ã æ¢çŽ¢ç©ºéãæäŸããã lr0
lr0 "ãšããããŒãš "lr0 "ãšããå€ãæã€èŸæžã䜿ãã tune.uniform(1e-5, 1e-1)
.æåŸã«ããšããã¯æ°ã®ãããªè¿œå ã®ãã¬ãŒãã³ã°åŒæ°ãã次ã®ããã«ãã¥ãŒãã³ã°ã¡ãœããã«çŽæ¥æž¡ããŸãã epochs=50
.
ã¬ã€ã»ãã¥ãŒã³ã®çµæãåŠçãã
Ray Tune ã§ãã€ããŒãã©ã¡ãŒã¿ã®ãã¥ãŒãã³ã°å®éšãå®è¡ããåŸãåŸãããçµæã«ã€ããŠæ§ã ãªåæãè¡ ããããšæããããããŸããããã®ã¬ã€ãã§ã¯ããããã®çµæãåŠçã»åæããããã®äžè¬çãªã¯ãŒã¯ãããŒã玹ä»ããŸãã
ãã£ã¬ã¯ããªããã®ãã¥ãŒãã³ã°å®éšçµæã®èªã¿èŸŒã¿
ã䜿ã£ããã¥ãŒãã³ã°å®éšãè¡ã£ãåŸã次ã®ããã«è¿°ã¹ãã tuner.fit()
ãã£ã¬ã¯ããªããçµæãããŒãã§ããŸããããã¯ãç¹ã«æåã®ãã¬ãŒãã³ã°ã¹ã¯ãªãããçµäºããåŸã«åæãå®è¡ããå Žåã«äŸ¿å©ã§ãã
experiment_path = f"{storage_path}/{exp_name}"
print(f"Loading results from {experiment_path}...")
restored_tuner = tune.Tuner.restore(experiment_path, trainable=train_mnist)
result_grid = restored_tuner.get_results()
åºæ¬çãªå®éšã¬ãã«ã®åæ
ãã©ã€ã¢ã«ã®çµæã®æŠèŠãææ¡ã§ããŸãããã©ã€ã¢ã«äžã«ãšã©ãŒããªãã£ããã©ãããããã«ç¢ºèªããããšãã§ããŸãã
åºæ¬çãªãã©ã€ã¢ã«ã¬ãã«ã®åæ
åã ã®ãã©ã€ã¢ã«ã®ãã€ããŒãã©ã¡ãŒã¿æ§æãšãæåŸã«å ±åãããã¡ããªã¯ã¹ã«ã¢ã¯ã»ã¹ããŸãã
for i, result in enumerate(result_grid):
print(f"Trial #{i}: Configuration: {result.config}, Last Reported Metrics: {result.metrics}")
èšåºè©Šéšã§å ±åãããã¡ããªã¯ã¹ã®å šå±¥æŽããããããã
åè©Šéšã§å ±åãããã¡ããªã¯ã¹ã®å±¥æŽãããããããŠãã¡ããªã¯ã¹ã®çµæå€åãèŠãããšãã§ããŸãã
import matplotlib.pyplot as plt
for i, result in enumerate(result_grid):
plt.plot(
result.metrics_dataframe["training_iteration"],
result.metrics_dataframe["mean_accuracy"],
label=f"Trial {i}",
)
plt.xlabel("Training Iterations")
plt.ylabel("Mean Accuracy")
plt.legend()
plt.show()
æŠèŠ
ãã®ããã¥ã¡ã³ãã§ã¯ãUltralytics ã䜿çšã㊠Ray Tune ã§å®è¡ãããå®éšçµæã解æããããã®äžè¬çãªã¯ãŒã¯ãããŒã«ã€ããŠèª¬æããŸããäž»ãªã¹ãããã«ã¯ããã£ã¬ã¯ããªããã®å®éšçµæã®ããŒããåºæ¬çãªå®éšã¬ãã«ããã³ãã©ã€ã¢ã«ã¬ãã«ã®è§£æã®å®è¡ãã¡ããªã¯ã¹ã®ãããããªã©ããããŸãã
ãã€ããŒãã©ã¡ãŒã¿ãŒã®ãã¥ãŒãã³ã°å®éšãæ倧éã«æŽ»çšããããã«ãRay Tuneã®ãAnalyze ResultsïŒçµæã®åæïŒãããã¥ã¡ã³ãããŒãžãããã«è©³ããã芧ãã ããã
ããããã質å
Ray Tuneã䜿çšããŠãYOLO11 ã¢ãã«ã®ãã€ããŒãã©ã¡ãŒã¿ã調æŽããã«ã¯ïŒ
Ray Tune ã䜿çšããŠUltralytics YOLO11 ã¢ãã«ã®ãã€ããŒãã©ã¡ãŒã¿ããã¥ãŒãã³ã°ããã«ã¯ã以äžã®æé ã«åŸããŸãïŒ
-
å¿ èŠãªããã±ãŒãžãã€ã³ã¹ããŒã«ããïŒ
-
YOLO11 ããã¥ãŒãã³ã°ãéå§ããŸãïŒ
ããã¯ãRay Tuneã®é«åºŠãªæ€çŽ¢ã¹ãã©ããžãŒãšäžŠåæ§ãå©çšããŠãã¢ãã«ã®ãã€ããŒãã©ã¡ãŒã¿ãŒãå¹ççã«æé©åããŸãã詳ããã¯Ray Tuneã®ããã¥ã¡ã³ããã芧ãã ããã
Ray Tuneã§YOLO11 ãããã©ã«ãã®ãã€ããŒãã©ã¡ãŒã¿ã¯äœã§ããïŒ
Ultralytics YOLO11 ã¯ãRay Tune ã§ã®ãã¥ãŒãã³ã°ã«ä»¥äžã®ããã©ã«ãã®ãã€ããŒãã©ã¡ãŒã¿ã䜿çšããŸãïŒ
ãã©ã¡ãŒã¿ | å€ã®ç¯å² | 説æ |
---|---|---|
lr0 |
tune.uniform(1e-5, 1e-1) |
åæåŠç¿ç |
lrf |
tune.uniform(0.01, 1.0) |
æçµåŠç¿çä¿æ° |
momentum |
tune.uniform(0.6, 0.98) |
å¢ã |
weight_decay |
tune.uniform(0.0, 0.001) |
äœéæžå° |
warmup_epochs |
tune.uniform(0.0, 5.0) |
ãŠã©ãŒã ã¢ããã»ãšãã㯠|
box |
tune.uniform(0.02, 0.2) |
ããã¯ã¹ãã¹éé |
cls |
tune.uniform(0.2, 4.0) |
æžéã¯ã©ã¹ |
hsv_h |
tune.uniform(0.0, 0.1) |
è²çžå¢åŒ·ç¯å² |
translate |
tune.uniform(0.0, 0.9) |
翻蚳å¢åŒ·ç¯å² |
ãããã®ãã€ããŒãã©ã¡ãŒã¿ã¯ãç¹å®ã®ããŒãºã«åãããŠã«ã¹ã¿ãã€ãºããããšãã§ãããå®å šãªãªã¹ããšè©³çŽ°ã«ã€ããŠã¯ããã€ããŒãã©ã¡ãŒã¿ã®ãã¥ãŒãã³ã°ã»ã¬ã€ããåç §ããŠãã ããã
YOLO11 ã¢ãã«ã®ãã¥ãŒãã³ã°ã«Weights & Biases ãçµ±åããã«ã¯ïŒ
Weights & Biases (W&B) ãUltralytics YOLO11 ãã¥ãŒãã³ã°ã»ããã»ã¹ã«çµ±åããïŒ
-
W&Bãèšçœ®ããïŒ
-
ãã¥ãŒãã³ã°ã¹ã¯ãªãããä¿®æ£ããïŒ
ãã®ã»ããã¢ããã«ããããã¥ãŒãã³ã°ã»ããã»ã¹ãã¢ãã¿ãŒãããã€ããŒãã©ã¡ãŒã¿ã®èšå®ã远跡ããçµæãW&Bã§èŠèŠåããããšãã§ããã
YOLO11 ããã€ããŒãã©ã¡ãŒã¿ã®æé©åã«Ray Tuneã䜿ãã¹ãçç±ã¯ïŒ
ã¬ã€ã»ãã¥ãŒã³ã¯ããã€ããŒãã©ã¡ãŒã¿ã®æé©åã«ãããŠå€ãã®å©ç¹ãæäŸããïŒ
- é«åºŠãªæ€çŽ¢æŠç¥ïŒãã€ãºæé©åãHyperOptãªã©ã®ã¢ã«ãŽãªãºã ã掻çšããå¹ççãªãã©ã¡ãŒã¿æ€çŽ¢ãå®çŸã
- 䞊åæ§ïŒè€æ°ã®ãã©ã€ã¢ã«ã®äžŠåå®è¡ããµããŒããããã¥ãŒãã³ã°ããã»ã¹ãå€§å¹ ã«ã¹ããŒãã¢ããã
- æ©æåæ¢ïŒASHAã®ãããªæŠç¥ãæ¡çšããããã©ãŒãã³ã¹ã®äœãè©Šéšãæ©æã«çµäºãããèšç®è³æºãç¯çŽããã
Ray Tune ã¯Ultralytics YOLO11 ãšã·ãŒã ã¬ã¹ã«çµ±åããããã€ããŒãã©ã¡ãŒã¿ãå¹æçã«ãã¥ãŒãã³ã°ããããã®äœ¿ããããã€ã³ã¿ãŒãã§ã€ã¹ãæäŸããŸãããŸãã¯ãRay Tune ãšYOLO11ã䜿ã£ãå¹ççãªãã€ããŒãã©ã¡ãŒã¿ã®ãã¥ãŒãã³ã°ã¬ã€ããã芧ãã ããã
YOLO11 ãã€ããŒãã©ã¡ãŒã¿ã»ãã¥ãŒãã³ã°ã®ããã®ã«ã¹ã¿ã æ¢çŽ¢ç©ºéãå®çŸ©ããã«ã¯ïŒ
Ray Tune ã§YOLO11 ãã€ããŒãã©ã¡ãŒã¿ãã¥ãŒãã³ã°ã®ããã®ã«ã¹ã¿ã ãµãŒã空éãå®çŸ©ããïŒ
from ray import tune
from ultralytics import YOLO
model = YOLO("yolo11n.pt")
search_space = {"lr0": tune.uniform(1e-5, 1e-1), "momentum": tune.uniform(0.6, 0.98)}
result_grid = model.tune(data="coco8.yaml", space=search_space, use_ray=True)
ããã¯ããã¥ãŒãã³ã°ã»ããã»ã¹äžã«æ¢çŽ¢ãããåæåŠç¿çãéåéãªã©ã®ãã€ããŒãã©ã¡ãŒã¿ã®ç¯å²ãã«ã¹ã¿ãã€ãºãããé«åºŠãªèšå®ã«ã€ããŠã¯ãã«ã¹ã¿ã æ¢çŽ¢ç©ºéã®äŸã®ã»ã¯ã·ã§ã³ãåç §ããŠãã ããã