YOLO11 ã¢ãã«åœ¢åŒããTF.js ã¢ãã«åœ¢åŒãžã®ãšã¯ã¹ããŒã
æ©æ¢°åŠç¿ã¢ãã«ããã©ãŠã¶ãŒãNode.jsã«çŽæ¥ãããã€ããã®ã¯åä»ãªããšã§ããã¢ãã«ããŠãŒã¶ãŒã®ããã€ã¹äžã§ã€ã³ã¿ã©ã¯ãã£ããªã¢ããªã±ãŒã·ã§ã³ãããŒã«ã«ã«å®è¡ããããã«äœ¿çšã§ããããã«ãã¢ãã«ã®ãã©ãŒããããããé«éãªããã©ãŒãã³ã¹ã«æé©åãããŠããããšã確èªããå¿ èŠããããŸããTensorFlow.jsïŒãŸãã¯TF.jsïŒã®ã¢ãã«ãã©ãŒãããã¯ãé«éãªããã©ãŒãã³ã¹ãæäŸããªãããæå°éã®é»åãã䜿ããªãããã«èšèšãããŠããŸãã
TF.js ã¢ãã«åœ¢åŒãžã®ãšã¯ã¹ããŒããæ©èœã«ãããã¢ãã«ãæé©åããããšãã§ããŸãã Ultralytics YOLO11ã¢ãã«ãæé©åããããšãã§ããŸãããã®ã¬ã€ãã§ã¯ãã¢ãã«ãTF.js圢åŒã«å€æããæé ã説æããŸããããã«ãããæ§ã ãªããŒã«ã«ãã©ãŠã¶ãNode.jsã¢ããªã±ãŒã·ã§ã³äžã§ã¢ãã«ãããç°¡åã«åäœããããã«ãªããŸãã
ãªãTF.jsã«ãšã¯ã¹ããŒãããå¿ èŠãããã®ãïŒ
TensorFlow ã®ãšã³ã·ã¹ãã ã®äžéšãšããŠTensorFlow ããŒã ã«ãã£ãŠéçºãããTensorFlow.js ã«æ©æ¢°åŠç¿ã¢ãã«ããšã¯ã¹ããŒããããšãæ©æ¢°åŠç¿ã¢ããªã±ãŒã·ã§ã³ãå±éããéã«å€ãã®å©ç¹ããããŸããæ©å¯ããŒã¿ãããã€ã¹äžã«ä¿æããããšã§ããŠãŒã¶ãŒã®ãã©ã€ãã·ãŒãšã»ãã¥ãªãã£ã匷åããããšãã§ããŸããäžã®ç»åã¯ãTensorFlow.jsã®ã¢ãŒããã¯ãã£ãšãæ©æ¢°åŠç¿ã¢ãã«ãã©ã®ããã«å€æããããŠã§ããã©ãŠã¶ãšNode.jsã®äž¡æ¹ã§ãããã€ããããã瀺ããŠããŸãã
ãŸããããŒã«ã«ã§ã¢ãã«ãå®è¡ããããšã§ãåŸ ã¡æéãççž®ãããããå¿çæ§ã®é«ããŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ãåŸãããŸãã TensorFlowãŸãã.jsã¯ãªãã©ã€ã³æ©èœãåããŠããããããŠãŒã¶ãŒã¯ã€ã³ã¿ãŒãããæ¥ç¶ããªããŠãã¢ããªã±ãŒã·ã§ã³ã䜿çšããããšãã§ããŸããTF.jsã¯ãGPU ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ããµããŒãããã¹ã±ãŒã©ããªãã£ã®ããã«èšèšãããŠãããããéããããªãœãŒã¹ã®ããã€ã¹ã§è€éãªã¢ãã«ãå¹ççã«å®è¡ã§ããããã«èšèšãããŠããŸãã
TF.jsã®äž»ãªç¹åŸŽ
TF.jsãéçºè ã«ãšã£ãŠåŒ·åãªããŒã«ã«ããŠããäž»ãªæ©èœã玹ä»ãããïŒ
-
ã¯ãã¹ãã©ãããã©ãŒã ã®ãµããŒã: TensorFlow.js ã¯ããã©ãŠã¶ãš Node.js ã®äž¡æ¹ã®ç°å¢ã§äœ¿çšã§ãããããããŸããŸãªãã©ãããã©ãŒã ã«æè»ã«å¯Ÿå¿ã§ããŸããéçºè ã¯ãããç°¡åã«ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ãããããã€ããããšãã§ããŸãã
-
è€æ°ã®ããã¯ãšã³ãã®ãµããŒãïŒ TensorFlow.jsã¯ãCPU ãGPU ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã®ããã®WebGLããã€ãã£ãã«è¿ãå®è¡é床ã®ããã®WebAssemblyïŒWASMïŒãããã³é«åºŠãªãã©ãŠã¶ããŒã¹ã®æ©æ¢°åŠç¿æ©èœã®ããã®WebGPUãå«ãèšç®ã®ããã®æ§ã ãªããã¯ãšã³ãããµããŒãããŠããŸãã
-
ãªãã©ã€ã³æ©èœïŒ TensorFlow.jsã§ã¯ãã€ã³ã¿ãŒãããæ¥ç¶ãå¿ èŠãšããã«ãã©ãŠã¶äžã§ã¢ãã«ãå®è¡ã§ããããããªãã©ã€ã³ã§æ©èœããã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœã§ãã
TensorFlow.js ã§ã®å±éãªãã·ã§ã³
YOLO11 ã¢ãã«ãTF.js ãã©ãŒãããã«ãšã¯ã¹ããŒãããããã»ã¹ã«å ¥ãåã«ããã®ãã©ãŒãããã䜿çšãããå žåçãªãããã€ã·ããªãªãããã€ãæ¢ã£ãŠã¿ãŸãããã
TF.jsã«ã¯ãæ©æ¢°åŠç¿ã¢ãã«ããããã€ããããã®ããŸããŸãªãªãã·ã§ã³ãçšæãããŠããïŒ
-
ãã©ãŠã¶å MLã¢ããªã±ãŒã·ã§ã³ïŒæ©æ¢°åŠç¿ã¢ãã«ããã©ãŠã¶äžã§çŽæ¥å®è¡ãããŠã§ãã»ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ã§ããŸãããµãŒããŒãµã€ãã®èšç®ãäžèŠã«ãªãããµãŒããŒã®è² è·ã軜æžãããŸãã
-
Node.jsã¢ããªã±ãŒã·ã§ã³:ïŒ TensorFlow.jsã¯Node.jsç°å¢ãžã®ãããã€ããµããŒãããŠããããµãŒããŒãµã€ãã®æ©æ¢°åŠç¿ã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœã§ãããµãŒããŒã®åŠçèœåããµãŒããŒãµã€ãã®ããŒã¿ãžã®ã¢ã¯ã»ã¹ãå¿ èŠãšããã¢ããªã±ãŒã·ã§ã³ã«ç¹ã«æå¹ã§ãã
-
Chromeæ¡åŒµæ©èœïŒ TensorFlow.jsã䜿ã£ãChromeæ¡åŒµæ©èœã®äœæã¯ãèå³æ·±ãå±éã·ããªãªã ãäŸãã°ããŠãŒã¶ãŒããŠã§ãããŒãžå ã®ç»åãå³ã¯ãªãã¯ããŠãäºåã«èšç·ŽãããMLã¢ãã«ã䜿ã£ãŠç»åãåé¡ã§ãããããªæ¡åŒµæ©èœãéçºã§ãããTensorFlow.jsã¯ãæ©æ¢°åŠç¿ã«åºã¥ãå³æã®æŽå¯ãè£åŒ·ãæäŸããããã«ãæ¥åžžã®ãŠã§ãé²èŠ§äœéšã«çµ±åããããšãã§ããŸãã
YOLO11 ã¢ãã«ã®TensorFlow.js ãžã®ãšã¯ã¹ããŒã
YOLO11 ã¢ãã«ãTF.js ã«å€æããããšã§ãã¢ãã«ã®äºææ§ãšãããã€ã®æè»æ§ãæ¡åŒµã§ããŸãã
ã€ã³ã¹ããŒã«
å¿ èŠãªããã±ãŒãžãã€ã³ã¹ããŒã«ããã«ã¯ã以äžãå®è¡ããïŒ
ã€ã³ã¹ããŒã«ããã»ã¹ã«é¢ãã詳现ãªèª¬æãšãã¹ããã©ã¯ãã£ã¹ã«ã€ããŠã¯ãUltralytics ã€ã³ã¹ããŒã«ã¬ã€ããã芧ãã ãããYOLO11 ã«å¿ èŠãªããã±ãŒãžãã€ã³ã¹ããŒã«ããéã«ãäœããã®åé¡ãçºçããå Žåã¯ã解決çããã³ãã«ã€ããŠãããããåé¡ã¬ã€ããåç §ããŠãã ããã
䜿çšæ¹æ³
䜿ãæ¹ã®èª¬æã«å ¥ãåã«ãUltralytics YOLO11 ã®å šã¢ãã«ããšã¯ã¹ããŒãã«å¯Ÿå¿ããŠããããšã確èªããŠãããŸããã ã
䜿çšæ¹æ³
from ultralytics import YOLO
# Load the YOLO11 model
model = YOLO("yolo11n.pt")
# Export the model to TF.js format
model.export(format="tfjs") # creates '/yolo11n_web_model'
# Load the exported TF.js model
tfjs_model = YOLO("./yolo11n_web_model")
# Run inference
results = tfjs_model("https://ultralytics.com/images/bus.jpg")
ãµããŒããããŠãããšã¯ã¹ããŒããªãã·ã§ã³ã®è©³çŽ°ã«ã€ããŠã¯ãUltralytics é 眮ãªãã·ã§ã³ã®ããã¥ã¡ã³ãããŒãžãåç §ããŠãã ããã
ãšã¯ã¹ããŒããããYOLO11 TensorFlow .js ã¢ãã«ã®ãããã€
YOLO11 ã¢ãã«ãTF.js ãã©ãŒãããã«ãšã¯ã¹ããŒãããã®ã§ã次ã®ã¹ãããã¯ããããããã€ããããšã§ããTF.jsãå®è¡ããããã®æåã®ã¹ããããšããŠæšå¥šãããã®ã¯ YOLO("./yolo11n_web_model")
ã¡ãœããã䜿çšããã
ããããTF.jsã¢ãã«ã®ãããã€ã«é¢ãã詳ãã説æã¯ã以äžã®ãªãœãŒã¹ãã芧ãã ããïŒ
-
ã¯ããŒã æ¡åŒµæ©èœ:TF.js ã¢ãã«ã Chrome æ¡åŒµæ©èœã«ãããã€ããæ¹æ³ã«ã€ããŠã®éçºè åãããã¥ã¡ã³ãã§ãã
-
TensorFlow.jsãNode.jsã§å®è¡ãã:TensorFlow.jsãNode.jsã§çŽæ¥å®è¡ããTensorFlow ã
-
TensorFlow.js ã®ããã〠- ã¯ã©ãŠããã©ãããã©ãŒã äžã®Nodeãããžã§ã¯ã:TensorFlow.js ã¢ãã«ã®ã¯ã©ãŠããã©ãããã©ãŒã ãžã®ãããã€ã«é¢ããTensorFlow ããã°æçš¿ã
æŠèŠ
ãã®ã¬ã€ãã§ã¯ãUltralytics YOLO11 ã¢ãã«ãTensorFlow.js ãã©ãŒãããã«ãšã¯ã¹ããŒãããæ¹æ³ãåŠã³ãŸãããTF.jsã«ãšã¯ã¹ããŒãããããšã§ãYOLO11 ã¢ãã«ãããŸããŸãªãã©ãããã©ãŒã ã§æé©åããããã€ãã¹ã±ãŒã«ã§ããæè»æ§ãåŸãããŸãã
䜿ãæ¹ã®è©³çŽ°ã«ã€ããŠã¯ãTensorFlow.js å ¬åŒããã¥ã¡ã³ããã芧ãã ããã
Ultralytics YOLO11 ãä»ã®ãã©ãããã©ãŒã ããã¬ãŒã ã¯ãŒã¯ãšçµ±åããããã®è©³çŽ°ã«ã€ããŠã¯ãçµ±åã¬ã€ãã®ããŒãžããã§ãã¯ããããšããå¿ããªããããªãã®ãããžã§ã¯ãã§YOLO11 ãæ倧éã«æŽ»çšããããã®çŽ æŽããããªãœãŒã¹ãæºèŒã§ãã
ããããã質å
Ultralytics YOLO11 ã®ã¢ãã«ãTensorFlow.js ãã©ãŒãããã«ãšã¯ã¹ããŒãããã«ã¯ïŒ
Ultralytics YOLO11 ã¢ãã«ãTensorFlow.js (TF.js) ãã©ãŒãããã«ãšã¯ã¹ããŒãããã®ã¯ç°¡åã§ãã以äžã®æé ã«åŸã£ãŠãã ããïŒ
䜿çšæ¹æ³
from ultralytics import YOLO
# Load the YOLO11 model
model = YOLO("yolo11n.pt")
# Export the model to TF.js format
model.export(format="tfjs") # creates '/yolo11n_web_model'
# Load the exported TF.js model
tfjs_model = YOLO("./yolo11n_web_model")
# Run inference
results = tfjs_model("https://ultralytics.com/images/bus.jpg")
ãµããŒããããŠãããšã¯ã¹ããŒããªãã·ã§ã³ã®è©³çŽ°ã«ã€ããŠã¯ãUltralytics é 眮ãªãã·ã§ã³ã®ããã¥ã¡ã³ãããŒãžãåç §ããŠãã ããã
ãªãYOLO11 ã®ã¢ãã«ãTensorFlow.js ã«ãšã¯ã¹ããŒãããå¿ èŠãããã®ã§ããïŒ
YOLO11 ã¢ãã«ãTensorFlow.js ã«ãšã¯ã¹ããŒããããšã以äžã®ãããªå©ç¹ããããŸãïŒ
- ããŒã«ã«å®è¡ïŒã¢ãã«ã¯ãã©ãŠã¶ãŸãã¯Node.jsã§çŽæ¥å®è¡ã§ãããããåŸ ã¡æéãççž®ããããŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ãåäžããŸãã
- ã¯ãã¹ãã©ãããã©ãŒã ã®ãµããŒã: TF.jsã¯è€æ°ã®ç°å¢ããµããŒãããŠãããæè»ãªãããã€ãå¯èœã§ãã
- ãªãã©ã€ã³æ©èœïŒã€ã³ã¿ãŒãããæ¥ç¶ããªããŠãã¢ããªã±ãŒã·ã§ã³ãæ©èœãããããšãã§ããä¿¡é Œæ§ãšãã©ã€ãã·ãŒã確ä¿ããŸãã
- GPU ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ïŒWebGL ã掻çšããŠGPU ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ãè¡ãããªãœãŒã¹ãéãããããã€ã¹ã§ã®ããã©ãŒãã³ã¹ãæé©åããŸãã
å æ¬çãªæŠèŠã«ã€ããŠã¯ã TensorFlow.js ãšã®çµ±åãã芧ãã ããã
TensorFlow.jsã¯ããã©ãŠã¶ããŒã¹ã®æ©æ¢°åŠç¿ã¢ããªã±ãŒã·ã§ã³ã«ã©ã®ãããªã¡ãªãããããããã®ãïŒ
TensorFlow.jsã¯ããã©ãŠã¶ãšNode.jsç°å¢ã§MLã¢ãã«ãå¹ççã«å®è¡ããããã«ç¹å¥ã«èšèšãããŠããŸããããã§ã¯ããã©ãŠã¶ããŒã¹ã®ã¢ããªã±ãŒã·ã§ã³ã«ã©ã®ãããªã¡ãªããããããã玹ä»ããŸãïŒ
- åŸ ã¡æéã®ççž®ïŒæ©æ¢°åŠç¿ã¢ãã«ãããŒã«ã«ã§å®è¡ããããããµãŒããŒãµã€ãã®èšç®ã«äŸåããããšãªããããã«çµæãåŸãããšãã§ããŸãã
- ãã©ã€ãã·ãŒã®åäžïŒæ©å¯ããŒã¿ããŠãŒã¶ãŒã®ããã€ã¹ã«ä¿æããã»ãã¥ãªãã£ãªã¹ã¯ãæå°éã«æããŸãã
- ãªãã©ã€ã³ã§ã®äœ¿çšãå¯èœïŒã€ã³ã¿ãŒãããã«æ¥ç¶ããŠããªãç¶æ ã§ãåäœãããããå®å®ããæ©èœã確ä¿ã§ããŸãã
- è€æ°ã®ããã¯ãšã³ãããµããŒãïŒ CPU ãWebGLãWebAssembly (WASM)ãWebGPUãªã©ãããŸããŸãªèšç®ããŒãºã«æè»ã«å¯Ÿå¿ããããã¯ãšã³ããæäŸããŸãã
TF.jsã«ã€ããŠãã£ãšç¥ãããã§ããïŒ TensorFlow.js å ¬åŒã¬ã€ããã芧ãã ããã
YOLO11 ã¢ãã«ããããã€ããããã®TensorFlow.js ã®äž»ãªæ©èœã¯äœã§ããïŒ
TensorFlow.jsã®äž»ãªç¹åŸŽã¯ä»¥äžã®éãïŒ
- ã¯ãã¹ãã©ãããã©ãŒã ã®ãµããŒã: TF.jsã¯ããŠã§ããã©ãŠã¶ãšNode.jsã®äž¡æ¹ã§äœ¿çšããããšãã§ããåºç¯ãªãããã€ã®æè»æ§ãæäŸããŸãã
- è€æ°ã®ããã¯ãšã³ãïŒ CPU ãGPU ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã®ããã® WebGLãWebAssembly (WASM)ãé«åºŠãªæäœã®ããã® WebGPU ããµããŒãããŠããŸãã
- ãªãã©ã€ã³æ©èœïŒã¢ãã«ã¯ã€ã³ã¿ãŒãããæ¥ç¶ãªãã§ãã©ãŠã¶äžã§çŽæ¥å®è¡ã§ãããããã¬ã¹ãã³ã·ãã»ãŠã§ãã»ã¢ããªã±ãŒã·ã§ã³ã®éçºã«æé©ã§ãã
ãããã€ã·ããªãªããã詳现ãªæ å ±ã«ã€ããŠã¯ã TensorFlow.js ã§ã®ãããã€ãªãã·ã§ã³ã®ã»ã¯ã·ã§ã³ãåç §ããŠãã ããã
TensorFlow.js ã䜿ã£ãŠãYOLO11 ã®ã¢ãã«ããµãŒããŒãµã€ãã® Node.js ã¢ããªã±ãŒã·ã§ã³ã«ãããã€ã§ããŸããïŒ
ã¯ããTensorFlow.jsã¯ãNode.jsç°å¢äžã§YOLO11 ã¢ãã«ã®ãããã€ãå¯èœã«ããŸããããã«ããããµãŒããŒã®åŠçèœåãšãµãŒããŒãµã€ãã®ããŒã¿ãžã®ã¢ã¯ã»ã¹ã掻çšãããµãŒããŒãµã€ãã®æ©æ¢°åŠç¿ã¢ããªã±ãŒã·ã§ã³ãå¯èœã«ãªããå žåçãªäœ¿çšäŸãšããŠã¯ãããã¯ãšã³ããµãŒããŒäžã§ã®ãªã¢ã«ã¿ã€ã ããŒã¿åŠçãæ©æ¢°åŠç¿ãã€ãã©ã€ã³ãããã
Node.jsã®ãããã€ãå§ããã«ã¯ãTensorFlow ã®ãRunTensorFlow.js in Node.jsãã¬ã€ããåç §ããŠãã ããã