Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CoreMLでアイドル顔認識アプリを作ろう

D2f212ce418f3daa29c23914c9b6892b?s=47 kenmaz
September 17, 2017

 CoreMLでアイドル顔認識アプリを作ろう

iOSDC Japan 2017 での発表資料です。
https://iosdc.jp/2017/

D2f212ce418f3daa29c23914c9b6892b?s=128

kenmaz

September 17, 2017
Tweet

Transcript

  1. $PSF.-ͰΞΠυϧإೝࣝ ΞϓϦΛ࡞Ζ͏ দલ݈ଠ࿠ !LFONB[ J04%$ 5SBDL"

  2. w ීஈ͸J04ΤϯδχΞ w ػցֶशͷઐ໳ՈͰ͸ͳ͘ɺ झຯͰษڧத ࣗݾ঺հ

  3. ຊτʔΫʹ͍ͭͯ wJ04ΤϯδχΞ͕ػցֶशʹνϟϯϨϯδͯ͠Έͨ wػցֶशٕज़ɾ$PSF.-Λ࢖ͬͨJ04ΞϓϦͷ։ൃϑ ϩʔΛ޿͘ઙ͘࿩͠·͢ɻ wʮࣗ෼Ͱ΋΍Εͦ͏ɺ͓΋͠Ζͦ͏ɺࢼͯ͠Έ͍ͨʯ ͱօ͞Μʹࢥ͍͚ͬͯͨͩΕ͹޾͍Ͱ͢

  4. /%"ʹ͍ͭͯ w$PSF.-΍J04ʹ͍ͭͯ͸ɺ/%" ͷؔ܎্ɺݱ࣌఺ͰҰൠެ։͞Εͯ ͍Δൣғͷ৘ใͷΈΛऔΓѻ͍·͢ wσϞϯετϨʔγϣϯ΍࣮ݧ݁Ռͷ ঺հͳͲ͸ߦ͍·ͤΜɻ

  5. લఏͱͳΔઐ໳஌ࣝ

  6. ΞΠυϧάϧʔϓ

  7. αϯϓϧࣄྫɿ ΞΠυϧإࣝผΞϓϦ Πϝʔδ ͸ͳ͜ 

  8. J04 7JTJPO $PSF.- ͓͞Β͍

  9. 7JTJPO

  10. 7JTJPO wը૾ೝࣝॲཧ༻ϑϨʔϜϫʔΫ wϝδϟʔͳը૾ೝࣝॲཧΛඪ४ Ͱఏڙ

  11. ग़యɿIUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED

  12. ग़యɿIUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED

  13. ग़యɿIUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED

  14. ग़యɿIUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED

  15. ࢖͍ํ 7/3FRVFTU)BOEMFS 7/3FRVFTU 7/0CTFSWBUJPO 7/0CTFSWBUJPO 7/0CTFSWBUJPO ࣮ߦ͍ͨ͠ը૾ೝࣝλεΫ ೖྗը૾ ந৅Խ͞Εͨೝࣝ݁Ռ

  16. ྫ إ෦඼ͷݕ஌ 7/%FUFDU'BDF-BOENBSLT 3FRVFTU 7/'BDF-BOENBSLT% GBDF$POUPVSʢྠֲҐஔʣ MFGU&ZFʢࠨ໨Ґஔʣ MFGU&ZFCSPXʢࠨ໨එҐஔʣ MFGU1VQJMʢࠨ໨؟ٿҐஔʣ OPTFʢඓҐஔʣ

    ʜ ػցֶश΍ը૾ೝࣝͷ ৄ͍͠஌ࣝ͸ෆཁ
  17. ओͳ7/3FRVFTUͷαϒΫϥε ༻్ 7/%FUFDU'BDF3FDUBOHMFT3FRVFTU إͷۣܗݕग़ 7/%FUFDU'BDF-BOENBSLT3FRVFTU إͷύʔπݕग़ 7/%FUFDU3FDUBOHMFT3FRVFTU ۣܗݕग़ 7/%FUFDU5FYU3FDUBOHMFT3FRVFTU ςΩετۣܗݕग़

    7/5SBDL0CKFDU3FRVFTU ෺ମݕग़ 7/%FUFDU)PSJ[PO3FRVFTU ਫฏݕग़ 7/*NBHF3FHJTUSBUJPO3FRVFTU ը૾ϨδετϨʔγϣϯ ʢҐஔ߹Θͤʣ 7/%FUFDU#BSDPEFT3FRVFTU όʔίʔυݕग़ 7/$PSF.-3FRVFTU ΧελϜͷ$PSF.-Λ༻͍ͨݕग़
  18. ओͳ7/3FRVFTUͷαϒΫϥε ༻్ 7/%FUFDU'BDF3FDUBOHMFT3FRVFTU إͷۣܗݕग़ 7/%FUFDU'BDF-BOENBSLT3FRVFTU إͷύʔπݕग़ 7/%FUFDU3FDUBOHMFT3FRVFTU ۣܗݕग़ 7/%FUFDU5FYU3FDUBOHMFT3FRVFTU ςΩετۣܗݕग़

    7/5SBDL0CKFDU3FRVFTU ෺ମݕग़ 7/%FUFDU)PSJ[PO3FRVFTU ਫฏݕग़ 7/*NBHF3FHJTUSBUJPO3FRVFTU ը૾ϨδετϨʔγϣϯ ʢҐஔ߹Θͤʣ 7/%FUFDU#BSDPEFT3FRVFTU όʔίʔυݕग़ 7/$PSF.-3FRVFTU ΧελϜͷ$PSF.-Λ༻͍ͨݕग़ ·ͣ͜ΕΒΛ࢖͑ͳ͍͔ݕ౼ ཁ݅ʹ߹Θͳ͚Ε͹ $PSF.-Λબ୒
  19. $PSF.-

  20. $PSF.- wػցֶशϑϨʔϜϫʔΫʢਪ࿦ͷΈʣ wσόΠε୯ମͰಈ࡞ w࣮ߦ࣌ʹαʔόʔෆཁɾߴ଎ɾηΩϡΞ w$16(16ʹ࠷దԽ͞Ε͓ͯΓύϫϑϧ

  21. $PSF.-Λ༻͍ͨΞϓϦͷߏ੒

  22. $PSF.-Λ༻͍ͨΞϓϦͷߏ੒ $PSF.-Ϟσϧ

  23. $PSF.-Λ༻͍ͨΞϓϦͷߏ੒ $PSF.-Ϟσϧ wωοτϫʔΫߏ଄ɺֶशࡁΈͷॏΈ

  24. $PSF.-Λ༻͍ͨΞϓϦͷߏ੒ $PSF.-Ϟσϧ wωοτϫʔΫߏ଄ɺֶशࡁΈͷॏΈ wυΩϡϝϯτϝλσʔλ

  25. $PSF.-Λ༻͍ͨΞϓϦͷߏ੒ $PSF.-Ϟσϧ wωοτϫʔΫߏ଄ɺֶशࡁΈͷॏΈ wυΩϡϝϯτϝλσʔλ wTXJGUPCKDͱͷ*'ͱͳΔΫϥεఆٛ

  26. $PSF.-Λ༻͍ͨΞϓϦͷߏ੒ $PSF.-Ϟσϧ wωοτϫʔΫߏ଄ɺֶशࡁΈͷॏΈ wυΩϡϝϯτϝλσʔλ wTXJGUPCKDͱͷ*'ͱͳΔΫϥεఆٛ

  27. IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED 'MPXFS$MBTTpFSNMNPEFM

  28. MFUJOQVU$71JYFM#V⒎FS MFUNPEFM'MPXFS$MBTTJpFS  MFUPVUQVUUSZNPEFMQSFEJDBUF qPXFS*NBHFJOQVU  QSJOU PVQVUqPXFS5ZQF

  29. $PSF.-ͷߏ੒ $PSF.-Ϟσϧ

  30. $PSF.-ͷߏ੒ Ͳ͏΍ͬͯ༻ҙ͢Δʁ $PSF.-Ϟσϧ

  31. ᶃ܇࿅ࡁΈͷ$PSF.-ϞσϧΛ࢖͏ ໊শ αΠζ ༻్ ࣝผྫ .PCJMF/FU .# ෺ମೝࣝ ໦ɺಈ෺ɺ৯΂෺ɺंɺਓͳͲ 4RVFF[F/FU

    .# 3FT/FU .# *ODFQUJPOW .# 7(( .# 1MBDF(PPH-F/FU .# γʔϯೝࣝ ۭߓɺ৸ࣨɺ৿ྛɺԊ؛ "QQMFެࣜఏڙ IUUQTEFWFMPQFSBQQMFDPNNBDIJOFMFBSOJOH
  32. ໊শ ༻్ $BS3FDPHOJUJPO ंͷϒϥϯυˍϞσϧࣝผ :0-0 ෺ମೝࣝ "HF/FU ਓؒͷإͷ೥ྸਪఆ (FOEFS/FU ਓؒͷإͷੑผਪఆ

    &NPUJPO/FU ਓؒͷإͷײ৘ਪఆ )&% Τοδநग़ 'PPE ྉཧͷࣝผ 0YGPSE Ֆͷछྨͷࣝผ -PDBUJPO/FU ࣸਅͷࡱӨ஍ਪఆ ͦͷଞͷެ։$PSF.-Ϟσϧ IUUQTHJUIVCDPNMJLFEBO"XFTPNF$PSF.-.PEFMT
  33. ໊শ ༻్ $BS3FDPHOJUJPO ंͷϒϥϯυˍϞσϧࣝผ :0-0 ෺ମೝࣝ "HF/FU ਓؒͷإͷ೥ྸਪఆ (FOEFS/FU ਓؒͷإͷੑผਪఆ

    &NPUJPO/FU ਓؒͷإͷײ৘ਪఆ )&% Τοδநग़ 'PPE ྉཧͷࣝผ 0YGPSE Ֆͷछྨͷࣝผ -PDBUJPO/FU ࣸਅͷࡱӨ஍ਪఆ ͦͷଞͷެ։$PSF.-Ϟσϧ IUUQTHJUIVCDPNMJLFEBO"XFTPNF$PSF.-.PEFMT ཁ݅ʹ߹͏΋ͷ͕ͳ͚Ε͹ ➔ࣗ෼Ͱ$PSF.-ϞσϧΛੜ੒͢Δ
  34. ᶄ$PSF.-5PPMTʹΑΔม׵ ܇࿅ࡁΈͷ ػցֶशϞσϧ 1ZUIPO

  35. ᶄ$PSF.-5PPMTʹΑΔม׵ ܇࿅ࡁΈͷ ػցֶशϞσϧ 1ZUIPO $PSF.-5PPMT ม׵

  36. ᶄ$PSF.-5PPMTʹΑΔม׵ ܇࿅ࡁΈͷ ػցֶशϞσϧ 1ZUIPO $PSF.-5PPMT ม׵

  37. ᶄ$PSF.-5PPMTʹΑΔม׵ ܇࿅ࡁΈͷ ػցֶशϞσϧ 1ZUIPO $PSF.-5PPMT ม׵ Ͳ͏΍ͬͯ༻ҙ͢Δʁ

  38. ᶄ$PSF.-5PPMTʹΑΔม׵ ᶃެ։͞Ε͍ͯΔ΋ͷΛ࢖͏ w$B⒎F.PEFM;PP w5FOTPS'MPX.PEFMT w.9/FU.PEFM;PP ᶄࣗ෼Ͱ࣮૷ͯ͠܇࿅͢Δ ܇࿅ࡁΈͷ ػցֶशϞσϧ 1ZUIPO $PSF.-5PPMT

    ม׵ Ͳ͏΍ͬͯ༻ҙ͢Δʁ
  39. 7JTJPO$PSF.- ͜͜·Ͱͷ·ͱΊ

  40. ը૾ೝࣝΛ࢖ͬͨΞϓϦͷ։ൃཁ݅ :&4 /0

  41. ը૾ೝࣝΛ࢖ͬͨΞϓϦͷ։ൃཁ݅ 7JTJPOͰ࣮૷Մೳʁ ᶃ7JTJPOϑϨʔϜϫʔΫΛ࢖͏ :&4 /0

  42. ը૾ೝࣝΛ࢖ͬͨΞϓϦͷ։ൃཁ݅ ࢖͑ͦ͏ͳֶशࡁΈ $PSF.-Ϟσϧ͕͋Δʁ 7JTJPOͰ࣮૷Մೳʁ ᶃ7JTJPOϑϨʔϜϫʔΫΛ࢖͏ ᶄֶशࡁΈ$PSF.-ϞσϧΛ࢖͏ :&4 /0

  43. ը૾ೝࣝΛ࢖ͬͨΞϓϦͷ։ൃཁ݅ ࢖͑ͦ͏ͳֶशࡁΈ $PSF.-Ϟσϧ͕͋Δʁ ࢖͑ͦ͏ͳ1ZUIPO࣮૷ͷ ֶशࡁΈϞσϧ͕͋Δʁ 7JTJPOͰ࣮૷Մೳʁ ᶃ7JTJPOϑϨʔϜϫʔΫΛ࢖͏ ᶄֶशࡁΈ$PSF.-ϞσϧΛ࢖͏ ᶅ$PSF.-5PPMTͰ $PSF.-Ϟσϧʹม׵ͯ͠࢖͏

    :&4 /0
  44. ը૾ೝࣝΛ࢖ͬͨΞϓϦͷ։ൃཁ݅ ࢖͑ͦ͏ͳֶशࡁΈ $PSF.-Ϟσϧ͕͋Δʁ ࢖͑ͦ͏ͳ1ZUIPO࣮૷ͷ ֶशࡁΈϞσϧ͕͋Δʁ ࣌ؒͱͱڭࢣσʔλͱ Ϡϧؾ͸͋Δʁ 7JTJPOͰ࣮૷Մೳʁ ᶃ7JTJPOϑϨʔϜϫʔΫΛ࢖͏ ᶄֶशࡁΈ$PSF.-ϞσϧΛ࢖͏

    ᶅ$PSF.-5PPMTͰ $PSF.-Ϟσϧʹม׵ͯ͠࢖͏ ᶆػցֶशͷίʔυΛ1ZUIPOͰ࣮૷ ˍ܇࿅ͯ͠ɺ$PSF.-5PPMTͰ $PSF.-Ϟσϧʹม׵ͯ͠࢖͏ :&4 /0
  45. ը૾ೝࣝΛ࢖ͬͨΞϓϦͷ։ൃཁ݅ ࢖͑ͦ͏ͳֶशࡁΈ $PSF.-Ϟσϧ͕͋Δʁ ࢖͑ͦ͏ͳ1ZUIPO࣮૷ͷ ֶशࡁΈϞσϧ͕͋Δʁ ࣌ؒͱͱڭࢣσʔλͱ Ϡϧؾ͸͋Δʁ 7JTJPOͰ࣮૷Մೳʁ ᶃ7JTJPOϑϨʔϜϫʔΫΛ࢖͏ ᶄֶशࡁΈ$PSF.-ϞσϧΛ࢖͏

    ᶅ$PSF.-5PPMTͰ $PSF.-Ϟσϧʹม׵ͯ͠࢖͏ ᶆػցֶशͷίʔυΛ1ZUIPOͰ࣮૷ ˍ܇࿅ͯ͠ɺ$PSF.-5PPMTͰ $PSF.-Ϟσϧʹม׵ͯ͠࢖͏ :&4 /0
  46. ը૾ೝࣝΛ࢖ͬͨΞϓϦͷ։ൃཁ݅ ࢖͑ͦ͏ͳֶशࡁΈ $PSF.-Ϟσϧ͕͋Δʁ ࢖͑ͦ͏ͳ1ZUIPO࣮૷ͷ ֶशࡁΈϞσϧ͕͋Δʁ ࣌ؒͱͱڭࢣσʔλͱ Ϡϧؾ͸͋Δʁ 7JTJPOͰ࣮૷Մೳʁ ᶃ7JTJPOϑϨʔϜϫʔΫΛ࢖͏ ᶄֶशࡁΈ$PSF.-ϞσϧΛ࢖͏

    ᶅ$PSF.-5PPMTͰ $PSF.-Ϟσϧʹม׵ͯ͠࢖͏ ᶆػցֶशͷίʔυΛ1ZUIPOͰ࣮૷ ˍ܇࿅ͯ͠ɺ$PSF.-5PPMTͰ $PSF.-Ϟσϧʹม׵ͯ͠࢖͏ :&4 /0 ➔ΞΠυϧإࣝผΞϓϦ
  47. ΞΠυϧإࣝผΞϓϦ ͷ։ൃ 

  48. શମઃܭ

  49. શମઃܭ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ

  50. શମઃܭ ϑϨʔϜը૾औಘ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ

  51. શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ

  52. શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ

  53. શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ ϝϯόʔͷࣝผ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ

  54. ͸ͳ͜ શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ ϝϯόʔͷࣝผ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ ࣝผ݁Ռͷදࣔ

  55. ͸ͳ͜ શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ ϝϯόʔͷࣝผ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ ࣝผ݁Ռͷදࣔ

    "7$BQUVSF
  56. ͸ͳ͜ શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ ϝϯόʔͷࣝผ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ ࣝผ݁Ռͷදࣔ

    "7$BQUVSF 7JTJPO 7/%FUFDU'BDF3FDUBOHMFT3FRVFTU
  57. ͸ͳ͜ શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ ϝϯόʔͷࣝผ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ ࣝผ݁Ռͷදࣔ

    "7$BQUVSF 7JTJPO 7/%FUFDU'BDF3FDUBOHMFT3FRVFTU $PSF.- ϝϯόʔإࣝผϞσϧ
  58. ͸ͳ͜ શମઃܭ ϑϨʔϜը૾औಘ إͷݕग़ ϝϯόʔͷࣝผ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ ࣝผ݁Ռͷදࣔ

    "7$BQUVSF 7JTJPO 7/%FUFDU'BDF3FDUBOHMFT3FRVFTU $PSF.- ϝϯόʔإࣝผϞσϧ
  59. $PSF.-Λ༻͍ͨΞϓϦͷ ։ൃϑϩʔ ᶃڭࢣσʔλ ͷ४උ ᶄϞσϧͷ ࣮૷ ᶅ܇࿅ ᶆֶशࡁΈ Ϟσϧͷม׵ ᶇΞϓϦ΁ͷ

    ૊ΈࠐΈ
  60. ᶃڭࢣσʔλ ͷ४උ ᶄϞσϧͷ ࣮૷ ᶅ܇࿅ ᶆֶशࡁΈ Ϟσϧͷม׵ ᶇΞϓϦ΁ͷ ૊ΈࠐΈ ᶃϥϕϧ෇͖ڭࢣσʔλͷ४උ

  61. إը૾ͷऩू wΫϩʔϥͰը૾Λऩू wը૾ݕࡧ"1*ɺεΫϨΠϐϯά w4DSBQZ IUUQTTDSBQZPSH  wΫϩʔϦϯάɾεΫϨΠϐϯά༻ϑϨʔϜϫʔΫ wDTTηϨΫλΛͪΐΖͬͱॻ͚ͩ͘ wաෛՙ๷ࢭɺSPCPUTUYUΛߟྀͨ͠ྱّਖ਼͍͠ΫϩʔϦϯά

  62. $ scrapy runspider momospider.py import scrapy from crawler.items import MomoItem

    class MomoSpider(scrapy.Spider): name = "momo" start_urls = [“https://momo.com/blog/“] def parse(self, response): image_url = response.css('#main #content .artwork img::attr(src-swap)').extract_first() member_name = response.css('#title h1::text').extract_first() item = MomoItem() item['image_urls'] = [image_url] item['member_name'] = member_name return item
  63. લॲཧ w0QFO$7Ͱͬ͘͟Γإ෦෼ͷ੾Γൈ͖ wඍົͳ܏͖΍ζϨ͕ਫ਼౓ʹӨڹΛ༩͑Δ wը૾ճసɺ໨ඓޱͷҐஔ߹Θͤ ࢀߟɿإೝࣝҐஔ߹Θͤͷॏཁੑ

  64. ֤ϝϯόʔຕY ຕͷڭࢣσʔλΛऩू

  65. ֤ϝϯόʔຕY ຕͷڭࢣσʔλΛऩू ख࡞ۀͰ ϥϕϧ෇͚ʂ NBDͷ'JOEFSͰϑΝΠϧΛख࡞ۀͰ෼ྨ

  66. ᶃڭࢣσʔλ ͷ४උ ᶄϞσϧͷ ࣮૷ ᶅ܇࿅ ᶆֶशࡁΈ Ϟσϧͷม׵ ᶇΞϓϦ΁ͷ ૊ΈࠐΈ ᶄϞσϧͷ࣮૷

  67. ࣝผϞσϧ ΞΠυϧإࣝผϞσϧ

  68. ࣝผϞσϧ ΞΠυϧإࣝผϞσϧ ೖྗɿY3(#ͷإը૾ ϥϕϧ෇͖ڭࢣը૾ ͸ͳ͜ ೖྗ

  69. ࣝผϞσϧ ΞΠυϧإࣝผϞσϧ ϝϯόʔ ֬཰ ΕΈ  ͸ͳ͜  ͓͍͠ 

    ͋ʔΓͦ  ΋΋͜  ਪ࿦ ग़ྗ֤ϝϯόʔͷ֬཰ ೖྗɿY3(#ͷإը૾ ϥϕϧ෇͖ڭࢣը૾ ͸ͳ͜ ೖྗ
  70. ࣝผϞσϧ ΞΠυϧإࣝผϞσϧ ϝϯόʔ ֬཰ ΕΈ  ͸ͳ͜  ͓͍͠ 

    ͋ʔΓͦ  ΋΋͜  ਪ࿦ ग़ྗ֤ϝϯόʔͷ֬཰ ೖྗɿY3(#ͷإը૾ ϥϕϧ෇͖ڭࢣը૾ ͸ͳ͜ ೖྗ ɹֶश
  71. ࣝผϞσϧ ΞΠυϧإࣝผϞσϧ ϝϯόʔ ֬཰ ΕΈ  ͸ͳ͜  ͓͍͠ 

    ͋ʔΓͦ  ΋΋͜  ਪ࿦ ग़ྗ֤ϝϯόʔͷ֬཰ ˠը૾ͷଟΫϥε෼ྨ໰୊ ೖྗɿY3(#ͷإը૾ ϥϕϧ෇͖ڭࢣը૾ ͸ͳ͜ ೖྗ ɹֶश
  72. ը૾ͷଟΫϥε෼ྨ໰୊ wը૾ೝࣝͷ෼໺Ͱ͸ϝδϟʔͳ໰୊ wσʔληοτ΍αϯϓϧ࣮૷΋ଟ਺ެ։͞ Ε͍ͯΔ w৞ΈࠐΈχϡʔϥϧωοτϫʔΫʢ$//ʣ ग़యɿIUUQTXXXUFOTPSqPXPSHHFU@TUBSUFENOJTUCFHJOOFST ग़యɿIUUQTXXXDTUPSPOUPFEVdLSJ[DJGBSIUNM

  73. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ݩը૾

  74. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ݩը૾ ϑΟϧλ

  75. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ݩը૾ ϑΟϧλ ৞ΈࠐΈ

  76. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ݩը૾ ϑΟϧλ ಛ௃ͷநग़ ৞ΈࠐΈ

  77. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ݩը૾ ϑΟϧλ ಛ௃ͷநग़ ৞ΈࠐΈ ϓʔϦϯά

  78. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ݩը૾ ϑΟϧλ ಛ௃ͷநग़ ඍখͳҐஔมԽ ʹର͢Δෆมੑ Λ࣮ݱ ৞ΈࠐΈ ϓʔϦϯά

  79. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ΕΈ ͸ͳ͜ ͓͍͠ ͋ʔΓͦ ΋΋͜

  80. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ৞ΈࠐΈ૚ɾϓʔϦϯά૚ ΕΈ ͸ͳ͜ ͓͍͠ ͋ʔΓͦ ΋΋͜

  81. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ৞ΈࠐΈ૚ɾϓʔϦϯά૚ શ݁߹૚ ΕΈ ͸ͳ͜ ͓͍͠ ͋ʔΓͦ ΋΋͜

  82. ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ ʢࡶͳઆ໌ʣ ৞ΈࠐΈ૚ɾϓʔϦϯά૚ શ݁߹૚ ΕΈ ͸ͳ͜ ͓͍͠ ͋ʔΓͦ ΋΋͜ ˠϑΟϧλͷύϥϝʔλɺ݁߹ͷॏΈΛֶश

  83. ػցֶशϥΠϒϥϦ w੍໿ w$PSF.-5PPMT͕αϙʔτ͍ͯ͠ Δ΋ͷΛબ୒͢Δ wόʔδϣϯ΋ݫີʹ߹ΘͤΔ ➔,FSBT 1ZUIPOΛ࠾༻

  84. ,FSBT෇ଐͷαϯϓϧίʔυ DJGBS@DOOQZ Λϕʔεʹ࣮૷

  85. ᶃڭࢣσʔλ ͷ४උ ᶄϞσϧͷ ࣮૷ ᶅ܇࿅ ᶆֶशࡁΈ Ϟσϧͷม׵ ᶇΞϓϦ΁ͷ ૊ΈࠐΈ ᶅ܇࿅

  86. Ϋϥ΢υ্Ͱͷֶश w(16Ϛγϯ͸ඞਢ w.#1 $16Ͱ਺೔͔͔Δॲཧ͕(16 ͳΒ਺࣌ؒͰ͢Ή w"84&$Q εϙοτΠϯελϯε wdIఔ౓ wڭࢣσʔλը૾͸Tʹ഑ஔ 4

    FD
  87. ؀ڥߏங w"84%FFQ-FBSOJOH".*T wIUUQTBXTBNB[PODPNKQBNB[POBJBNJT w(16υϥΠό΍ґଘϥΠϒϥϦ͕ΠϯετʔϧࡁΈ wىಈ͢Δ͚ͩͰʢ΄΅ʣ͙͢࢖͑Δ

  88. ֶश݁Ռ ΤϙοΫֶश ޙͷਫ਼౓ ܇࿅σʔλ ݕূσʔλ ͪΌΜͱͨ͠άϥϑʹ͢Δ

  89. ᶃڭࢣσʔλ ͷ४උ ᶄϞσϧͷ ࣮૷ ᶅ܇࿅ ᶆֶशࡁΈ Ϟσϧͷม׵ ᶇΞϓϦ΁ͷ ૊ΈࠐΈ ᶆֶशࡁΈϞσϧͷม׵

  90. $PSF.-Ϟσϧ΁ͷม׵

  91. $PSF.-Ϟσϧ΁ͷม׵ )%' ܗࣜ ɾωοτϫʔΫߏ଄ ɾֶशࡁΈͷॏΈ

  92. $PSF.-Ϟσϧ΁ͷม׵ )%' ܗࣜ ɾωοτϫʔΫߏ଄ ɾֶशࡁΈͷॏΈ

  93. $PSF.-Ϟσϧ΁ͷม׵ )%' ܗࣜ ɾωοτϫʔΫߏ଄ ɾֶशࡁΈͷॏΈ

  94. $PSF.-Ϟσϧ΁ͷม׵ )%' ܗࣜ ɾωοτϫʔΫߏ଄ ɾֶशࡁΈͷॏΈ 1 import coremltools 2 coreml_model

    = coremltools.converters.keras.convert( 3 'model.h5' 4 input_names = 'image', 5 image_input_names = 'image', 6 class_labels = 'labels.txt') 7 coreml_model.save(‘idle_classifer.mlmodel’)
  95. $PSF.-Ϟσϧͷݕূ

  96. $PSF.-Ϟσϧͷݕূ

  97. $PSF.-Ϟσϧͷݕূ ͸ͳ͜ 

  98. $PSF.-Ϟσϧͷݕূ ͸ͳ͜  ͸ͳ͜ 

  99. $PSF.-Ϟσϧͷݕূ ͸ͳ͜  ͸ͳ͜  ਖ਼͘͠ม׵Ͱ͖͍ͯΔ͜ͱ͕ݕূͰ͖ͨ

  100. $PSF.-Ϟσϧͷݕূ 1 import coremltools 2 img = load(‘hanako.png’) 3 model

    = coremltools.models.MLModel('Momomind.mlmodel') 4 res = model.predict(img) 5 print(res) # => ͸ͳ͜ 0.8888 ͸ͳ͜  ͸ͳ͜  ਖ਼͘͠ม׵Ͱ͖͍ͯΔ͜ͱ͕ݕূͰ͖ͨ
  101. $PSF.-5PPMT IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED ֤ϥΠϒϥϦ͝ͱͷ ίϯόʔλʔ 1ZUIPO$PSF.- PONBD04  ؒͷόΠϯσΟϯά ίϯόʔλʔߏங༻"1* w

    $PSF.-ϞσϧϑΥʔϚοτͷ࣮૷ w 9DPEFʹऔΓࠐΜͩࡍͷ*'ఆٛ
  102. ᶃڭࢣσʔλ ͷ४උ ᶄϞσϧͷ ࣮૷ ᶅ܇࿅ ᶆֶशࡁΈ Ϟσϧͷม׵ ᶇΞϓϦ΁ͷ ૊ΈࠐΈ ᶇΞϓϦ΁ͷ૊ΈࠐΈ

  103. ͸ͳ͜ ෦඼͸ἧͬͨ ϑϨʔϜը૾औಘ إͷݕग़ ϝϯόʔͷࣝผ Χϝϥө૾ͷ ϓϨϏϡʔදࣔ ݕग़ͨ͠إҐஔʹ ࿮Λදࣔ ࣝผ݁Ռͷදࣔ

    "7$BQUVSF 7JTJPO 7/%FUFDU'BDF3FDUBOHMFT3FRVFTU $PSF.- ϝϯόʔإࣝผϞσϧ
  104. ϑϨʔϜը૾औಘˍϓϨϏϡʔදࣔ let session = AVCaptureSession() let device = AVCaptureDevice.default(for: AVMediaType.video)!

    let deviceInput = try! AVCaptureDeviceInput(device: device) session.addInput(deviceInput) let previewLayer = AVCaptureVideoPreviewLayer(session: session) view.layer.insertSublayer(previewLayer, at: 0) let queue = DispatchQueue(label: “xxx") let output = AVCaptureVideoDataOutput() output.setSampleBufferDelegate(self, queue: queue) session.addOutput(output) func captureOutput(..., didOutput sampleBuffer: CMSampleBuffer, ..) { let buffer: CVImageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) ... } ᶃΧϝϥೖྗ ᶄϓϨϏϡʔදࣔ ᶅΩϟϓνϟग़ྗ ᶆϑϨʔϜը૾औಘ
  105. إҐஔݕग़ let buffer: CVImageBuffer = ... let inputImage = CIImage(cvImageBuffer:

    buffer) //ᶃإۣܗऔಘϦΫΤετ let handler = VNImageRequestHandler(ciImage: inputImage) handler.perform([ VNDetectFaceRectanglesRequest(completionHandler: { (req, err) in //ᶄإۣܗͷऔಘ let req = request as! VNDetectFaceRectanglesRequest, let faces = req.results as! [VNFaceObservation], let face = faces.first.boundingBox, let rect = face.boundingBox, //ᶅإ෦෼ͷ੾Γൈ͖ let faceImage: CIImage = cropImage(from inputImage, rect: rect)
  106. إࣝผ //ᶃֶशࡁΈCoreMLϞσϧͷϩʔυ let idleClassifier = IdleClassifier() let model = VNCoreMLModel(for:

    idleClassifier.model) //ᶄVision+CoreMLͰਪ࿦Λ࣮ߦ let image: CIImage = ... let handler = VNImageRequestHandler(ciImage: image) try handler.perform([ VNCoreMLRequest(model: model) {(req, err) in //ᶅࣝผ݁Ռͷऔಘ let res = req.results!.first as! VNClassificationObservation let name = res.identifier let probability = Int(res.confidence * 100) print(“ࣝผ݁Ռ \(name):\(probability)%”)
  107. ׬੒ʁ ͸ͳ͜

  108. ੒௕ʹΑΔإͷมԽ 

  109. ܧଓతͳ ࣝผਫ਼౓ͷ޲্

  110. ڭࢣσʔλͷ֦ॆ

  111. ޡݕ஌ͷใࠂػೳ 4 ͷͷ͔ إը૾ʴਖ਼ղϥϕϧ ͸ͳ͜ ໰୊Λใࠂ ਖ਼ղΛ͓͍͑ͯͩ͘͠͞ ͷͷ͔c ૹ৴

  112. IUUQNPNPNJOELFONB[OFU 4 ͋ʔΓͦ ޡݕ஌ͷใࠂػೳʢϒϥ΢β൛ʣ إը૾ʴਖ਼ղϥϕϧ

  113. ΫϩʔϥʔʹΑΔܧଓతͳऩू ˍԾϥϕϧ͚ͮ 4 Ϋϩʔϥʔ ਪ࿦ˍԾϥϕϧ෇͚ खಈ֬ೝˍमਖ਼ ΋΋͜ إը૾ʴʢԾͷʣਖ਼ղϥϕϧ

  114. ͸ͳ͜ ໰୊Λใࠂ ϥϕϧ෇͖ڭࢣσʔλͷ֦ॆ

  115. ͸ͳ͜ ໰୊Λใࠂ ϥϕϧ෇͖ڭࢣσʔλͷ֦ॆ ࠶ֶश

  116. ͸ͳ͜ ໰୊Λใࠂ ϥϕϧ෇͖ڭࢣσʔλͷ֦ॆ ࠶ֶश ʁ

  117. ͸ͳ͜ ࠶ੜ੒ͨ͠Ϟσϧͷಈతஔ׵ μ΢ϯϩʔυ NMNPEFM NMNPEFMD class MLModel { class func

    compileModel(at modelURL: URL) throws -> URL ίϯύΠϧ ୺຤಺ JOPVUͷ࢓༷มߋͳͲ ☓ ࢀߟɿ)PUTXBQQJOH$PSF.-NPEFMTPOUIFJ1IPOF
  118. ͸ͳ͜ ໰୊Λใࠂ ϥϕϧ෇͖ڭࢣσʔλͷ֦ॆ ࠶ֶश

  119. ͸ͳ͜ ໰୊Λใࠂ ϥϕϧ෇͖ڭࢣσʔλͷ֦ॆ ࠶ֶश $PSF.-Ϟσϧͷ ࠶ੜ੒ˍಈతஔ׵

  120. ͸ͳ͜ ໰୊Λใࠂ ϥϕϧ෇͖ڭࢣσʔλͷ֦ॆ ࠶ֶश $PSF.-Ϟσϧͷ ࠶ੜ੒ˍಈతஔ׵ ਫ਼౓޲্ͷϧʔϓ͕ॏཁ

  121. ΞϧΰϦζϜͷվળ w ຊτʔΫͷൣᙝ֎ w ೔ʑΞϧΰϦζϜ΍ςΫχοΫ͕ൃද͞Ε͍ͯΔ w ΩϟονΞοϓͯ͠ΈΔ w 2JJUBUBHTػցֶश w

    BS9JW$PNQVUFS7JTJPOBOE1BUUFSO3FDPHOJUJPO
  122. Ԡ༻

  123. ࣮ݧத ෆద੾ը૾ϦΞϧλΠϜݕ஌ Ϣʔβʔ͔Β௨ใ͞Εͨෆద੾ը૾ ΠϥετΛඳըதʹ ϦΞϧλΠϜʹ ෆద੾ը૾Λݕग़ IUUQBOJNFLFONB[OFU IUUQDIJOLPDIFDLFSLFONB[OFU 5FOTPSqPXͰݸਓαʔϏεʹΞοϓϩʔυ͞Εͨෆద੾ͳΠϥετը૾Λݕग़͢Δ "OJNF.BLFS

    J04ΞϓϦ"OESPJEΞϓϦ ෆద੾ͳඳࣸ ͸΍Ί·͠ΐ͏
  124. ࣮ݧத ࣗಈண৭ϚϯΨϏϡʔϫ ը૾ग़యɿΏΊΈΔΏͼ͖͞ϚϯΨϘοΫεΠϯσΟʔζ ("/ (FOFSBUJWF"EWFSTBSJBM/FUXPSLTBS9JW

  125. ࣮ݧத ࿝؟޲͚ϚϯΨϏϡʔϫ ը૾ग़యɿ࿀ͱӕʢӳޠ൛ʣϚϯΨϘοΫε w 7JTJPO"1*

  126. ࣮ݧத ࿝؟޲͚ϚϯΨϏϡʔϫ ը૾ग़యɿ࿀ͱӕʢӳޠ൛ʣϚϯΨϘοΫε w 7JTJPO"1*

  127. ࣮ݧத ࿝؟޲͚ϚϯΨϏϡʔϫ ը૾ग़యɿ࿀ͱӕʢӳޠ൛ʣϚϯΨϘοΫε w 7JTJPO"1*

  128. ࣮ݧத ࿝؟޲͚ϚϯΨϏϡʔϫ ը૾ग़యɿ࿀ͱӕʢӳޠ൛ʣϚϯΨϘοΫε w 7JTJPO"1*

  129. ࣮ݧத ࿝؟޲͚ϚϯΨϏϡʔϫ ը૾ग़యɿ࿀ͱӕʢӳޠ൛ʣϚϯΨϘοΫε w 7JTJPO"1*

  130. ΞΠσΞ࣍ୈʁ wͳ෦෼΋͋Δ wॳظJ1IPOFΞϓϦ։ൃϒʔϜͷࠒʹΑ͘ࣅͯΔʁ wཧ࿦͸೉͍͕͠ɺָ͍͠

  131. ·ͱΊ w7JTJPO $PSF.-Ͱը૾ೝࣝɾػցֶशٕज़ Λ࢖ͬͨΞϓϦͷ։ൃϋʔυϧ͕Լ͕ͬͨ wܧଓతͳਫ਼౓ͷ޲্ͷͨΊͷ؀ڥͮ͘Γ΋ॏཁ wΞΠσΞ࣍ୈͰՄೳੑ͕޿͕Δ wͨͩ͠ػցֶशͷجૅ஌ࣝ΋΍͸Γॏཁ

  132. ػցֶशʹαΠΤϯςΟετ͚ͩͷ΋ͷ ͬͯ͜ͱ͸·ͬͨ͘ͳ͍ʂ

  133. DIBMMFOHF

  134. ࢀߟจݙ w ͍Β͢ͱ΍ʮΞΠυϧʯͷݕࡧ݁Ռ w .BDIJOF-FBSOJOH"QQMF w ਂ૚ֶश%FFQ-FBSOJOHʢۙ୅Պֶࣾʣ w ਂ૚ֶशʢػցֶशϓϩϑΣογϣφϧγϦʔζʣ w

    θϩ͔Β࡞Δ%FFQ-FBSOJOH w 5FOTPSqPXCFHJOOFST w DJGBS w ("/ (FOFSBUJWF"EWFSTBSJBM/FUXPSLTBS9JW w )PUTXBQQJOH$PSF.-NPEFMTPOUIFJ1IPOF w إೝࣝҐஔ߹Θͤͷॏཁੑ