$30 off During Our Annual Pro Sale. View Details »

MediaPipe と ML Kit ってどう ちがうの? / What is the dif...

Yuki Anzai
November 30, 2024

MediaPipe と ML Kit ってどう ちがうの? / What is the difference between MediaPipe and ML Kit?

Yuki Anzai

November 30, 2024
Tweet

More Decks by Yuki Anzai

Other Decks in Technology

Transcript

  1. .FEJB1JQF w 0QFOTPVSDFNBDIJOFMFBSOJOHGSBNFXPSL w POEFWJDF w DSPTTQMBUGPSN "OESPJE J04 8FC

    1ZUIPO  w .FEJB1JQF'SBNFXPSL w ޮ཰తͳPOEFWJDF.-QJQFMJOFΛߏங͢ΔͨΊʹ࢖༻͞ΕΔMPXMFWFMίϯϙʔ ωϯτ w .FEJB1JQF4PMVUJPOT w ΞϓϦέʔγϣϯʹػցֶशͷػೳΛ૊ΈࠐΉͨΊͷϥΠϒϥϦͱπʔϧ܈ 4 https://github.com/google-ai-edge/mediapipe
  2. .FEJB1JQF w 0QFOTPVSDFNBDIJOFMFBSOJOHGSBNFXPSL w POEFWJDF w DSPTTQMBUGPSN "OESPJE J04 8FC

    1ZUIPO  w .FEJB1JQF'SBNFXPSL w ޮ཰తͳPOEFWJDF.-QJQFMJOFΛߏங͢ΔͨΊʹ࢖༻͞ΕΔMPXMFWFMίϯϙʔ ωϯτ w .FEJB1JQF4PMVUJPOT w ΞϓϦέʔγϣϯʹػցֶशͷػೳΛ૊ΈࠐΉͨΊͷϥΠϒϥϦͱπʔϧ܈ 5 https://github.com/google-ai-edge/mediapipe
  3. Ϟσϧબ୒ͷ༗ແ 11 MediaPipe Solutions ML Kit w ར༻͢ΔϞσϧΛࣗ෼ͰબͿ w ਪ঑Ϟσϧ͕༻ҙ͞Ε͍ͯΔ

    w CVJMEJOͷϞσϧ͕࢖ΘΕΔ w Ұ෦ͷػೳͰ͸ΧελϜϞσϧͷར ༻͕Մೳ
  4. Ϟσϧͷ഑෍ 12 MediaPipe Solutions ML Kit w ϞσϧΛΞϓϦ಺ʹ഑ஔ w CVJMEJOϞσϧ

    w ϥΠϒϥϦͱҰॹʹϞσϧΛΞϓϦʹCVOEMF w (PPHMFQMBZTFSWJDFTͰμ΢ϯϩʔυ w ΧελϜϞσϧʢରԠ͍ͯ͠ΔػೳͷΈʣ w ϞσϧΛΞϓϦ಺ʹ഑ஔ w 'JSFCBTF.-ʹϞσϧΛϗετ w (PPHMFQMBZTFSWJDFTͰμ΢ϯϩʔυ w fi SFCBTFNMNPEFMEPXOMPBEFSͰμ΢ϯϩʔυ
  5. 14 val baseOptions = BaseOptions.builder() .setModelAssetPath("efficientnet_lite0.tflite") .build() val options =

    ImageClassifier.ImageClassifierOptions .builder() .setBaseOptions(baseOptions) … .build() imageClassifier = ImageClassifier.createFromOptions(context, options) MediaPipe Solutions αϯϓϧίʔυ https://github.com/google-ai-edge/mediapipe-samples AGP, Gradle ͕ݹ͍ͷͰ஫ҙ implementation("com.google.mediapipe:tasks-vision:0.20230731")
  6. 15 ML Kit val options = ImageLabelerOptions.Builder() .setConfidenceThreshold(0.6f) .build() labeler

    = ImageLabeling.getClient(options) // bundled : About 5.7 MB size increase. implementation("com.google.mlkit:image-labeling:17.0.9") or // unbundled : About 200 KB size increase. // Model is dynamically downloaded via Google Play Services. implementation("com.google.android.gms:play-services-mlkit-image-labeling:16.0.8")
  7. Ϟσϧͷҧ͍ 16 MediaPipe Solutions Image classi fi cation ML Kit

    Image Labeling w & ffi DJFOU/FU-JUF w *NBHF/FUͰֶशͨ͠छྨͷ Ϋϥε w IUUQTTUPSBHFHPPHMFBQJTDPN NFEJBQJQFUBTLTJNBHF@DMBTTJ fi FS MBCFMTUYU w छྨͷϥϕϧ w IUUQTEFWFMPQFSTHPPHMFDPN NMLJUWJTJPOJNBHFMBCFMJOH MBCFMNBQ
  8. ઃఆͰ͖Δ߲໨ͷҧ͍ 18 MediaPipe Solutions Image classi fi cation ML Kit

    Image Labeling ImageClassifier.ImageClassifierOptions .builder() .setScoreThreshold(0.3f) .setMaxResults(3) .setRunningMode(RunningMode.LIVE_STREAM) .setDisplayNamesLocale("ja") .setCategoryAllowlist(…) or .setCategoryDenylist(…) ImageLabelerOptions.Builder() .setConfidenceThreshold(0.3f)
  9. 21

  10. 22 MediaPipe Solutions val baseOptions = BaseOptions.builder() .setModelAssetPath("vision_classifier_birds_v3.tflite") .build() val

    options = ImageClassifier.ImageClassifierOptions .builder() .setBaseOptions(baseOptions) … .build() imageClassifier = ImageClassifier.createFromOptions(context, options)
  11. 25 ML Kit (Bundled) val localModel = LocalModel.Builder() .setAssetFilePath("vision_classifier_birds_v3.tflite") //

    or .setAbsoluteFilePath(absolute file path to model file) // or .setUri(URI to model file) .build() val options = CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.3f) .setMaxResultCount(5) .build() labeler = ImageLabeling.getClient(options) implementation("com.google.mlkit:image-labeling-custom:17.0.3")
  12. 26 ML Kit (Bundled) val localModel = LocalModel.Builder() .setAssetFilePath("vision_classifier_birds_v3.tflite") //

    or .setAbsoluteFilePath(absolute file path to model file) // or .setUri(URI to model file) .build() val options = CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.3f) .setMaxResultCount(5) .build() labeler = ImageLabeling.getClient(options) 26 implementation("com.google.mlkit:image-labeling-custom:17.0.3")
  13. 29

  14. 30

  15. 31

  16. 32 ML Kit (Unbundled : Google Play Services Ͱμ΢ϯϩʔυ) val

    remoteModel = CustomRemoteModel .Builder(FirebaseModelSource.Builder("vision_classifier_food").build()) .build() val downloadConditions = DownloadConditions.Builder().requireWifi().build() RemoteModelManager.getInstance() .download(remoteModel, downloadConditions) .addOnSuccessListener { val options = CustomImageLabelerOptions.Builder(remoteModel) .setConfidenceThreshold(0.1f) .setMaxResultCount(5) .build() labeler = ImageLabeling.getClient(options) } implementation("com.google.android.gms:play-services-mlkit-image-labeling-custom:16.0.0-beta5") implementation("com.google.mlkit:linkfirebase:17.0.0")
  17. 33 ML Kit (Unbundled : fi rebase-ml-modeldownloader Ͱμ΢ϯϩʔυ) val conditions

    = CustomModelDownloadConditions.Builder().requireWifi().build() FirebaseModelDownloader.getInstance() .getModel("vision_classifier_food", DownloadType.LOCAL_MODEL, conditions) .addOnSuccessListener { model -> model?.file?.let { val localModel = LocalModel.Builder() .setAbsoluteFilePath(it.absolutePath) .build() val customImageLabelerOptions = CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.1f) .setMaxResultCount(5) .build() labeler = ImageLabeling.getClient(customImageLabelerOptions) } } implementation("com.google.firebase:firebase-ml-modeldownloader:25.0.1")
  18. 34

  19. .FEJB1JQF.PEFM.BLFS w ϕʔεͷϞσϧΛసҠֶश w Ұ෦ͷػೳ͕ରԠʢ0CKFDU %FUFDUJPO΍*NBHF $MBTTJ fi DBUJPOͳͲʣ w

    $PMBC͕༻ҙ͞Ε͍ͯΔ 36 https://ai.google.dev/edge/mediapipe/solutions/model_maker
  20. ·ͱΊ w 8FC΍1ZUIPOͰ࢖͍͍ͨˠ.FEJB1JQF4PMVUJPOT w ࢖͍͍ͨػೳ͕Ұํʹ͔͠ͳ͍ˠػೳ͕͋Δ΄͏ w Ϟσϧͷѻ͍Λ͓·͔͍ͤͨ͠ˠ.-,JU w 0CKFDU%FUFDUJPO *NBHF-BCFMJOHҎ֎ͰΧελϜϞσϧΛ࢖͍͍ͨˠ

    .FEJB1JQF4PMVUJPOT w 0CKFDU%FUFDUJPO *NBHF-BCFMJOHͷΧελϜϞσϧΛΞϓϦʹόϯυϧͨ͘͠ͳ ͍ˠ.-,JU w ͍ΖΜͳػցֶशػೳ͕؆୯ʹΞϓϦʹ૊ΈࠐΊΔΑ͏ʹͳͬͯΔ͔Βࢼͯ͠Έͯʂ 39