How can I set tflite PoseNet "Single-Person Pose Estimation" on Flutter? - flutter

I'm on a project that uses tflite Posenet to run on a mobile with Flutter Framework. We wanted more precision score on our tests, but we realized that the repository which is given us by the original example on Dart API docs https://pub.dev/documentation/tflite/latest/ uses Multi-Person Pose Estimation by defalt. (Repository mentioned:https://github.com/shaqian/flutter_realtime_detection).
We know that the original tfjs repository talks about it and give examples https://github.com/tensorflow/tfjs-models/tree/master/posenet but we can't find it on Dart API for flutter.
How can I set Single-Person Pose Estimation?

There is another tflite_flutter plugin which is actively being developed: https://pub.dev/packages/tflite_flutter. Please take a look.
This plugin allows you to run any custom .tflite model, so you should be able to download the single person posenet model provided from the official TFLite site here: https://www.tensorflow.org/lite/models/pose_estimation/overview.
There aren't any official flutter examples, but you should be able to refer to the Android/iOS examples to see how to pre-process / post-process the data.

Hy guys, updating the issue:
We maneged it after some tests with the Tflite.runPoseNetOnImage function. This function has a property called numResults, wich we can set to "1". Tflite.runPoseNetOnFrame has the same property.
You can see it in this link (https://pub.dev/documentation/tflite/latest/)

Related

Firebase 9 & Flutter: How to initializeApp?

I am desperately trying to figure out how to initializeApp with Flutter (not React Native).
I know about the functions to use, but I can not find the firebaseConfig I need to pass into the function.
And no matter what I search for, every resources references to React Native, like as if nobody codes with Flutter since Firebase 9 has been released anymore (or I am the only dummy which is not able to resolve this by myself).
Can someone tell me where to get the firebaseConfig object from?
If I add a new app to my project, I only get the google-services.json, which does NOT include the firebaseConfig object I need to pass.
I understand your confusion now, let me explain. When the guy in the video talks about Firebase v9 he is talking about the SDK version which in the case of Javascript (which I suppose is his main topic in his channel) is currently 9.17.1 an the version 9 has been around since 2021 so it is not new. The different SDKs have their own versions for each platform so thinking it will be the same in every SDK is a mistake by itself. You can check the SDKS here. So there is no Firebase v9, there is a Firebase SDK for javascript version 9. They managed in that way in javascript and in flutter it is not the same. Being that the last update in the flutter SDK was literally yesterday I'm pretty sure they have their reasons to not implement the same functions in flutter since 2021.
Now, one of the thinks the guy talks in the video is deconstructing, which is something common in javascript. The way you do this in flutter is by using show.
So you would be doing this for example:
import 'package:cloud_firestore/cloud_firestore.dart' show FirebaseFirestore, QuerySnapshot; //Add everything you would be using
This way only the specific parts of the library will be imported and the amount of code the Dart VM has to load will be reduced.
As of the access to documents, it is still the same but you can easily create a helper class that contents your references to your collections and then just use that class to reduce the boilerplate code created by the firebase SDK.
You have to install the Firebase CLI and run firebase init.
You need to use the package firebase_core that will give you access to the class Firebase so you can use it to initialize your app Firebase.initializeApp() you can pass the default options for the current platform using Firebase.initilizeApp(options: DefaultFirebaseOptions.currentPlatform) usually your IDE will automatically import the corresponding package but in case it does not you would have to import 'firebase/firebase_options.dart';
An useful link to the documentation: Add Firebase to your Flutter App

How to integrate my own tflite model on Flutter?

I have completed a tensorflow model than converted it correctly to tflite in order to use it in a mobile app using flutter. I didn't know how to integrate a personalized tflite model with flutter. All the available examples use the pretrained models. When I tried my model, the camera launches for a while and stops immediately!
I followed the source code from this link which uses the "tflite" pacakge : https://medium.com/#shaqian629/real-time-object-detection-in-flutter-b31c7ff9ef96
I added my own tflite model alongside with other models in all the ".dart" files and in "pubspec.yaml".
you can try the 'tflite_flutter' package. 'tflite' package is not suitable for custom trained models as you will get shape incompatible error message

Has anyone successfully run a MoveNet model using tflite in Flutter?

I am trying to use MoveNet in Flutter using tflite. If anyone has experience with it or example with the implementation, an example would be appreciated.
I have successfully implemented MoveNet singlepose lightning model with tflite_flutter on my Flutter application. You can refer to this repo I made: https://github.com/AGRapista/FitnessInstructor The code you should be interested in is in lib/test.dart

How do I actually install and use YouTube Android Player API?

I want to make a Flutter app that can play YouTube playlists using the YouTube Android Player API, found here: https://developers.google.com/youtube/android/player
The "Getting started" instructions say:
The following documents will help you to set up your development environment and use the YouTube Android Player API:
The download page provides a link to download the API client library
and JavaDocs.
The instructions for registering your application explain how to
register your app in the Google API Console and to obtain an Android
API key, which you will need to use the API.
The setup instructions explain how to set up an API project using
either Eclipse or IntelliJ.
The sample applications overview describes the sample applications
included in the API download.
The JavaDoc reference provides detailed definitions of the API's
interfaces, classes, methods, and enums.
I've followed every step in those points and links, but I still don't know how to use the provided package in my code! I now have a sample app running on my phone, and apparently using the package... which is cute... but it is in Java, which I don't speak, so it doesn't help me make my own app! Plain English instructions would have been more helpful...
I have tried:
import 'com.google.android.youtube.player'
and even:
import '<path>/YouTubeAndroidPlayerApi.jar'
but Dart Analysis tells me the URL doesn't exists. And when I try any of the classes that are supposed to be included in the package, I get that it's not defined.
I've tried right-clicking on the YouTubeAndroidPlayerApi.jar file and choosing "Add as library", but same result.
So what I normally do is to write something in my pubspec.yaml file, like:
dependencies:
provider: ^4.3.2+3
Then I would run pub get.
Then I would write import <package name> in my code, and now the classes will be ready to use.
What is the correspondence in this case? What am I supposed to do with this package so that I can use the classes in my code? I'm using Android Studio.
Most grateful for guidance!

How to use platform channels with FlutterView or Flutter.createFragment

I just saw the flutter roadmap mentioning a preview of adding flutter to existing project.
I am still not sure how to use platform channels when using FlutterView or Flutter.createFragment. Usually they are available in the FlutterActivity instance.
You create a new instance of the channel and pass in your FlutterView. This documentation gives a good overview.