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

15分でわかる、Flutter ML 世界 @FlutterGakkai

15分でわかる、Flutter ML 世界 @FlutterGakkai

第3回 FlutterGakkai
15分でわかる、Flutter ML 世界
Jai-Chang Park (@Dreamwalker)

JaiChangPark

January 28, 2023
Tweet

More Decks by JaiChangPark

Other Decks in Programming

Transcript

  1. Park JaiChang (@Dreamwalker) • ᖃଐ: Dreamus Company • Flutter Seoul:

    Organizer • GDG Golang Korea: Organizer • @jaichangpark • Github: JAICHANGPARK • Flutter / Android / Go / Rust ᥦ࿭ᖖ෨ ᩲ3ỹ FlutterGakkai 2
  2. ኷ᶝ ! • Κ͔͡Ν᭳ዧ • Flutter͹ML (Machine Learning)᧱ᠭ͞൱ၙͼ΀Ħ • Flutter͹MLϧόϰΤͻ΀Κ͘ͽᑿᠭͩΐͫ͝Ħ

    • ͻͥ͝ΛᘿΓΝ΀͝Ρ͝ΜΐͭΥ🥹 • ⬇ • Flutter x ML(Machine Learning)αΩώ (ͽͼΞ΂͖͖͹ͫͿ..) ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 4
  3. Agenda 1. Flutter 2. ML 3. Flutter x ML ᩲ3ỹ

    FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 5
  4. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.1. FlutterͽͶ͖͸ Flutter is an

    open source framework by Google for building beautiful, natively compiled, multi-platform applications from a single codebase. https://flutter.dev/ 7
  5. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.1. FlutterͽͶ͖͸ ͼͮDart᜔Ͳ͵ͱĦ🎯 • Flutter

    TeamΔ෺ൃᰮ࿴ͽ΁਺ၞ͡΀ϜϲεϮϤϸε᜔ͺϮϸτΩϥΤວᅝͩ͸͟ͱg • ͯ΀͘ͳDart᜔͞Flutter φ⑲ϥ΀᠓ཏͺ࿥᫿ͽରͫΝξθΧ͞ີ͝͵ͱg • React Native΁JS(JaveScript)Τᑿ͘gJaveScriptͯ΀ᥦମΤม๞ͩͽ͖͡g • (Dart == Google && Flutter == Google)͞ᬤ͵͸͖Νᅪg • Dart᜔΁ᡯʑAoT(Ahead-of-Time) Compiler΁ͼ͝͵ͱg • Dartφ⑲ϥ͞Flutterφ⑲ϥ΀ͱΓͽṐᅪͩ͸AoTω⑲ϰφά⑲ϸ(Toolchain)Τ෺ൃͫΝg • Dart VM(Virtual Machine)΀ᱠ᧱ặ 9
  6. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.1. FlutterͽͶ͖͸ https://docs. fl utter.dev/resources/architectural-overview#architectural-layers

    Architectural layers 1. Framework - Dart Lang 2. Engine - C/C++ - Rendering : Skia, Impeller 3. Embedder - Platform-speci fi c 10
  7. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.1. FlutterͽͶ͖͸ Architectural layers 1.

    Framework - Dart Lang 2. Engine - C/C++ - Rendering : Skia, Impeller 3. Embedder - Platform-speci fi c 11
  8. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.1. FlutterͽͶ͖͸ • ϜϮψύϚή⑲ϥ΀࿸ၙΤFlutter Framework͹ᑿᠭͫΝͽ΁ͻͫ͘Ξ΂Κ

    ͖͹ͫ͝Ħ • ᆚ͚΂fAndroid, iOS΀Platform΀࿸ၙΤᑿ͖ͱ͖Ĉ • Platform Channel • FFI (Foreign Function Interface) 👇 12
  9. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.2. Platform Channel 1. Hardware΀࿸ၙ

    • Bluetooth, BLE • Camera 2. ݖݶ • Permission https:// fl utter.dev/multi-platform/mobile 3. πϸκ⑲ᨼᏄďᲩĐ • Acc, Gyro, Mag 4. TCP/IP Socket 5. ͼͻg 13
  10. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.2. Platform Channel • Kotlin

    or Java on Android • Swift or Objective-C on iOS • C++ on Windows • Objective-C on macOS • C on Linux https://docs. fl utter.dev/development/platform-integration/platform- channels?tab=type-mappings-c-plus-plus-tab 14
  11. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.2. Platform Channel Method Channel

    • Asynchronous Method ! • ϜϮψύϚή⑲ϥͺᴢᙩͫΝͱΓͽ ᑿᠭͧΞΝφϨϒϰ Method Channel = Future Event Channel • Asynchronous! • ϜϮψύϚή⑲ϥ͹Event Streamďξύϯ⑲ϥĐΤᗀᙩͫ ΝͱΓͽᑿᠭͧΞΝφϨϒϰ Event Channel = Stream 15
  12. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.2. Platform Channel Κ͔͡Ν᭳ዧ ͖Ζf

    ီ͖ͩͩfᏝࡶ͹ͫͿgᶶֶͬΈᶶ᠓͔ΝĦ ᬰ͵͸͜͡΋͟͹ͫ͝Ħ 😡🤯 16
  13. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1.2. Platform Channel ML ϧόϰ΁࿥Ꮳ᧣ͽ

    Native Platform ͹࣮ḝͧΞΐͫg ͶΐΜfᬰ͵͸͜͡ͺ᜽ͽርͳΐͫg 17
  14. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 1. Flutter Recap (᠓ᛱ) 1.

    Flutter΁Google΀Flutter Team͝Λ෺ൃͩͱOpen Source UI Toolkit͹ ͔Νg • Dart, Multi-Platform, Declarative UI 2. Architecture • Framework, Engine, Embedder 3. Platform Channel • Method Channel, Event Channel 18
  15. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 2.1. Machine LearningͽͶ͖͸ AI Arti

    fi cial Intelligence Machine Learning Deep Learning Χϰιϯοϥͺ ᱠ᧱ặ΀ઓ͖ 20
  16. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 2.1. Machine LearningͽͶ͖͸ Data Input

    Black Box Model ෺ൃ Model ֶश Model Test Retraining Model Deploy User Feedback ෰ᔭ 21
  17. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 2.2. ML΀ϮΩϛϮϯ • TensorFlow •

    TensorFlow.js • TensorFlow Lite (TinyML) • Keras • Pytorch • Other ML API Service • Ex) Open AI 2.0 22
  18. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ Machine Learning

    Model 1. ͫ͹ͽΚ͡ᥭΛΞͱϧόϰΤᑿ͘ 2. ᥦᐠ͹ᥭΝ 3. APIΤớᠭͫΝ 24
  19. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 26 https://www.tensor

    fl ow.org/lite/android MobileΖEmbeddedỖ๕ͽᑿ͚Ν TensorFlow Lite Microcontrollers͹Δᑿ͚ t fl ite model
  20. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 30 fi

    rebase_ml_vision 0.12.0+3 https://pub.dev/packages/ fi rebase_ml_vision OCT 21, 2021
  21. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 31 This

    package is now discontinued since these APIs are no longer available in the latest Firebase SDKs. As an alternative you can switch to Google's standalone ML Kit library via google_ml_kit for on-device vision APIs. For calling the Cloud Vision API from your app the recommended approach is using Firebase Authentication and Functions, which gives you a managed, serverless gateway to Google Cloud Vision APIs. For an example Functions project see the vision-annotate-images sample project.
  22. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 32 google_ml_kit

    0.13.0 Access᥀: 2023-01-27 https://pub.dev/packages/google_ml_kit
  23. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 33 Google

    ML Kit - google_ml_kit ࿥᫿ 1. Vision APIs • ը૾ʹϥϕϧΛ෇͚ͯը૾ʹϥϕϧΛ෇͚ɺόʔ ίʔυɺςΩετɺإɺΦϒδΣΫτΛݕग़͢Δ APIg • Face mesh Τ᩹͡ ͫ΋͸ᑿᠭ൱ၙ 2. Natural Language APIs • 58 ᜡ᜔ණ΀຋༁ΤᙣᎭͩ͸຋༁ͩfጿᙩΤᩮᚳͫΝᥦ᝔ ᜡ᜔ॲሑ APIg • ͫ΋͸ᑿᠭ൱ၙ
  24. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 34 🤔ΰξτϥϧόϰ΁

    ͻͫ͘Ξ΂͖͖͹ͫ͝Ħ ࿆΁ML Kit΀ϘϰώͧΞͱ ϧόϰΤᑿ͵͸͖ΝΚ͘͹ͫ͞…
  25. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 35 https://pub.dev/packages/

    fi rebase_ml_model_downloader fi rebase_ml_model_downloader FirebaseͽΧψϜϲ⑲ώͧΞͱΰξτϥϧόϰΤυΫϸϲ⑲ώ͹͟ΐͫg Access᥀ 2023-01-27
  26. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 37 🤔

    ͔΀t fl te͵͸ͻͥ͝υΫϸϲ⑲ώ͹͟ΐͫĦ 1. ᥭᕧͩͱֶᘯϧόϰΤt fl iteϚΦΩϰͽมỐ • https://www.tensor fl ow.org/lite/guide/model_maker?hl=ja • Tensor fl ow Lite Model Maker 2. Tensor fl ow Hub • https://www.tensor fl ow.org/hub?hl=ko • TensorFlow Hub ΁fύϱ⑲ϐϸεࡁΑ΀࿸ຂֶᘯϧόϰ΀ϯϢνύϯ͹ͫg
  27. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.1. ᱠ᙮΀Flutter MLύϱϸώ 39 🤔

    Chat Bot(φϨψύϡψύ)΀Κ͘ͼμξϋϥ΁ĦĦ 1. Dialog fl ow • dialog fl ow_ fl utter 1.0.0 2. GPT3 from OpenAI • openai_gpt3_api • gpt_3_dart • fl utter_chatgpt_api • chat_gpt_sdk • chat_gpt_api • chat_gpt_ fl utter
  28. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.2. MLϧόϰΤ᧱ᠭͫΝ 40 t fl

    iteΤυΫϸϲ⑲ώͩ͸ᑿ͘ PackageΤᑿ͘ Assets Folder Firebase ML Custom Tensor fl ow Hub ᥦᐠ͹ᥭΝ Firebase_ml_mod el_downloader t fl ite & t fl ite_ fl utter t fl ite model google_ml_kit End End Start Web͹ᑿ͘ TensorFlow.js ᥦᐠ͹PackageᥭΝ End
  29. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.2. MLϧόϰΤ᧱ᠭͫΝ 41 dependencies -

    pubspec.yaml - PackageΤඦ୯ͽᱮ൰͹ ͟Νg ᆚ) PackageΤᑿ͘
  30. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.3. Holobooth-Flutter Forward Edition 42

    https://photobooth. fl utter.dev/ Δͩf ͥΞ͚֮͸͖ΐͫ͝Ħ Google I/O 22
  31. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ 3.3. Holobooth-Flutter Forward Edition 44

    1. Flutter 2. Firebase 3. TensorFlow.js detect the user’s face within the frame of the camera 4. MediaPipe estimates 468 3D face landmarks in real-time https://medium.com/ fl utter/how-its- made-holobooth-6473f3d018dd https://github.com/ fl utter/holobooth
  32. ᩲ3ỹ FlutterGakkai 15ᐠ͹Ρ͝ΝfFlutter ML ᕴ຅ ΐͺΓ 47 1. Flutter •

    Google΀Flutter Team͝Λ෺ൃͩͱOpen Source UI Toolkit͹͔Νg • Dart, Multi-Platform, Declarative UI 2. Flutter x ML • TensorFlow, PyTorch, ML API • KeyPoint 👉 Κ͡ᥭΛΞͱMLϧόϰΤϫ⑲λ⑲࣮᩺͞ͽᑿᠭ͹͟ΝΚ͘ͽͫΝͥͺ͹͔Νg • 1) ͫ͹ͽΚ͡ᥭΛΞͱϧόϰΤᑿ͘ 2) ᥦᐠ͹ᥭΝ 3) APIΤớᠭͫΝ • Flutter - MLઐ༻ύοέʔδ͕ଘࡏ, google_ml_kit (MLKit) 3. Flutter Forward Holobooth • Tensor fl ow.js, MediaPipe