YOLOで遊ぶ / pyml-niigata-20181013

YOLOで遊ぶ / pyml-niigata-20181013

Python機械学習勉強会 in 新潟 Restart #2 で発表した資料

82d6167c4d14393c2e20b37a74b363c5?s=128

kasacchiful

October 13, 2018
Tweet

Transcript

  1. YOLOͰ༡Ϳ Pythonػցֶशษڧձ in ৽ׁ 2018/10/13 @kasacchiful

  2. ࣗݾ঺հ • ּݪ ޺ (@kasacchiful) • ৽ׁࢢࡏॅ • Ruby͕͓ؾʹೖΓ •

    JaSST৽ׁ࣮ߦҕһ • JAWS-UG৽ׁࢧ෦ • ୈ1ճษڧձΛ11݄24೔(౔)ʹ։࠵ܾఆʂ
  3. એ఻

  4. ઌ݄NDSͰ͜Μͳ࿩͠·ͨ͠ • ࢿྉ: https://speakerdeck.com/kasacchiful/nds57 • σϞιʔε: https://github.com/kasacchiful/nds57-sample/blob/master/ nds57_vgg16_sample.ipynb

  5. OSC 2018 Niigata Ͱ஻Γ·͢ IUUQTXXXPTQOKQPTDOJJHBUBNPEVMFTFHVJEFFWFOUQIQ FJE

  6. JAWS-UG ৽ׁࢧ෦ઃཱ • 11݄24೔(౔)ʹୈ1ճษڧձΛ։࠵ʂ IUUQTKBXTVHOJJHBUBDPOOQBTTDPN

  7. ຊ୊

  8. ໨࣍ • YOLOͬͯԿʁ෺ମݕग़ͬͯԿʁ • ·ͣ͸ಈ͔ͯ͠ΈΑ͏ • ΧελϜֶशͤͯ͞ΈΑ͏

  9. ໨࣍ • YOLOͬͯԿʁ෺ମݕग़ͬͯԿʁ • ·ͣ͸ಈ͔ͯ͠ΈΑ͏ • ΧελϜֶशͤͯ͞ΈΑ͏

  10. YOLOͬͯԿʁ • ෺ମݕग़(Object Detection)ͷ࣮૷ͷ1ͭ • ଞʹ΋ɺFaster R-CNN΍SSDͳͲ͕͋Δ • DarknetϑϨʔϜϫʔΫ্Ͱߏங (C࣮૷)

    → Keras࣮૷ͳͲ΋͋Δ • ࠓ೥य़ʹv3ެ։ ( https://arxiv.org/abs/1804.02767 ) • v2͕19૚ → v3͕53૚ • ݕग़଎౓͕एׯ஗͘ͳ͕ͬͨɺݕग़ਫ਼౓͕େ෯Ξοϓ • “You Only Live Once" Λ΋ͬͯ͡ɺ”You Only Look Once”
  11. ෺ମݕ஌ͬͯԿʁ • ͋Δը૾ͷத͔ΒఆΊΒΕͨ෺ମͷΧςΰϦ(Ϋϥ ε)ͱͦͷҐஔΛݕग़ • ڭࢣ͋Γֶशͷ෼ྨʹ૬౰ • ಈըʹ΋ద༻Մೳ • ෺ମͷҐஔ͸ɺ෺ମͷྖҬΛۣܗͰғͬͨΓɺྖ

    ҬΛॴఆͷ৭ͰృΓͭͿͨ͠Γ
  12. ྫ͑͹͜Μͳײ͡ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg

  13. ެࣜͷσϞΛݟͯΈΑ͏ IUUQTQKSFEEJFDPNEBSLOFUZPMP

  14. ෺ମݕ஌ͷྺ࢙ ྖҬީิͷબఆ ಛ௃ྔͷநग़ ػցֶशͰ෼ྨ ैདྷ ྖҬީิͷબఆ σΟʔϓϥʔχϯά R-CNN Fast R-CNN

    Faster R-CNN YOLO SSD σΟʔϓϥʔχϯά
  15. ෺ମݕ஌ͷࣄྫ • LIXIL (ABEJA SIX 2018Ͱͷߨԋ) • γεςϜΩονϯΛ࢖ͬͨਓؒͷߦಈ෼ੳʹ෺ମݕ஌Λ׆༻ • ෺ମݕ஌ͷϩά͔Βɺ࢖͍΍͍͢γεςϜΩονϯͷ։ൃʹͭͳ͍͛ͯΔ

    • ෺ମݕ஌ʹ͸SSD͕࢖ΘΕ͍ͯΔ • ࢀߟ: • https://six2018.abejainc.com/reports/ • https://logmi.jp/279849
  16. ໨࣍ • YOLOͬͯԿʁ෺ମݕग़ͬͯԿʁ • ·ͣ͸ಈ͔ͯ͠ΈΑ͏ • ΧελϜֶशͤͯ͞ΈΑ͏

  17. darknetΠϯετʔϧ $ git clone https://github.com/pjreddie/darknet $ cd darknet $ make

  18. ඞཁʹԠͯ͡Makefile΋ฤू GPU=0 #=> NVIDIAͷGPU͕࢖͑ͯɺCUDA͕ΠϯετʔϧࡁͳΒ1ʹ CUDNN=0 OPENCV=0 #=> OPENCV͕ΠϯετʔϧࡁͳΒ1ʹ OPENMP=0 DEBUG=0

  19. Makefileमਖ਼ͨ͠Β࠶౓make $ make

  20. ࢼ͠ʹ࣮ߦ $ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg

  21. ͜Μͳײ͡ʹग़ྗ͞ΕΔ ݁Ռ͸predictions.jpgʹग़ྗ

  22. σϞ

  23. ໨࣍ • YOLOͬͯԿʁ෺ମݕग़ͬͯԿʁ • ·ͣ͸ಈ͔ͯ͠ΈΑ͏ • ΧελϜֶशͤͯ͞ΈΑ͏

  24. GPU͕ແ͍ͱπϥΠͷͰ • ֶश؀ڥ: • Amazon EC2 p2.xlarge Πϯελϯε • GPU:

    NVIDIA K80 (Google Colabͱಉ͡) • Deep Learning Base AMI (Ubuntu) Ver.10.0 • CUDAΠϯετʔϧࡁ
  25. darknetΠϯετʔϧ $ git clone https://github.com/pjreddie/darknet $ cd darknet

  26. Makefileฤू GPU=1 CUDNN=0 OPENCV=0 OPENMP=0 DEBUG=0

  27. make $ make

  28. ֶशͷྲྀΕ 1. ը૾ΛूΊΔ 2. Ξϊςʔγϣϯ͢Δ 3. ը૾Λਫ૿͢͠Δʢࠓճ͸লུʣ 4. ֶश͢Δ

  29. ࠓճͷֶश಺༰ • ΠλϦΞϯͷը૾ͷத͔ΒɺΠλϦΞϯͷྖҬΛ ݕग़ • class਺: 1ͭ (ΠλϦΞϯ͚ͩ) • ը૾͸72ຕ

    • ຊ౰͸΋ͬͱूΊΔඞཁ͕͋Δ͚Ͳɺࠓճ͸গ ྔͷσʔλͰ΍ͬͯΈΔ
  30. 1. ը૾ΛूΊΔ • ΠλϦΞϯͷը૾ΛूΊΔ • Bing Search API v7Λ࢖ͬͯɺը૾Λ700ຕ͘ Β͍ूΊͯɺͦͷத͔Β࢖͑ͦ͏ͳը૾Λ72

    ຕબͿ
  31. 2. Ξϊςʔγϣϯ͢Δ • ը૾ʹҐஔ৘ใΛՃ͑ͯɺڭࢣσʔλΛ࡞੒͢Δ • ࠓճ͸ɺVoTTΛ࢖༻ • https://github.com/Microsoft/VoTT • VoTT͸YOLOͷܗࣜͰग़ྗͯ͘͠ΕΔͷͰศར

    • Ξϊςʔγϣϯ࡞ۀ͸ɺσʔλ͕ଟ͚Ε͹ଟ͍΄Ͳɺख ؒͱ͕͔͔࣌ؒΔͷͰେม͕ͩɺػցֶशͷΩϞʹͳΔ
  32. 3. ը૾Λਫ૿͢͠Δ • ࠓճ͸໘౗ͩͬͨͷͰ΍͍ͬͯͳ͍ • ݩͷը૾͔ΒϥϯμϜʹͣΒͨ͠Γɺճస͞ ͤͨΓͱɺมܗͤͨ͞ը૾Λ࡞੒ͯ͠ɺը૾ Λ૿΍͢

  33. 4. ֶश͢Δ • Ξϊςʔγϣϯͨ͠ڭࢣσʔλΛdarknetͷ ϑΥϧμʹίϐʔ͠ɺֶशΛ࣮ߦ • ࠓճ͸VoTT͕ग़ྗͨ͠YOLOͷcfgΛ࢖༻

  34. ڭࢣσʔλΛల։ $ unzip italian_output.zip $ cd darknet/cfg $ mv ~/italian_output

    ./italian $ cd italian $ ls data yolo-obj.cfg $ ls data obj obj.data obj.names test.txt train.txt $ ls data/obj 000001.jpg 000001.txt 000002.jpg 000002.txt ...
  35. ֶश $ cd ~/darknet $ ./darknet detector train ./cfg/italian/data/obj.data \

    ./cfg/italian/yolo-obj.cfg
  36. ਪ࿦ $ cd ~/darknet $ ./darknet detector test ./cfg/italian/data/obj.data \

    ./cfg/italian/yolo-obj.cfg \ ./backup/yolo-obj_500.weights \ ./italian1.jpg
  37. ͜Μͳײ͡ʹग़ྗ͞ΕΔ ݁Ռ͸predictions.jpgʹग़ྗ

  38. σϞ

  39. ·ͱΊ • ෺ମݕ஌΋ɺ਺ʑͷ࣮૷͕ొ৔͍ͯ͠ΔͷͰɺൺ ֱత؆୯ʹࢼͤ·͢ • ֶश༻σʔλͷऩूͱΞϊςʔγϣϯ͕͠ΜͲ͍ • YOLO΍SSDΛࢼ͢ྫ͸ൺֱతଟ͍ • Keras౳Ͱͷ࣮૷΋͋ΔͷͰɺࢼͯ͠Έ͍ͯͩ͘͞