People always hear others talking about machine learning but only have a fuzzy idea of what that means. Often they find it difficult to implement machine learning models but don’t worry, Teachable Machine got you covered.
Teachable Machine is a web-based tool by Google aiming to make AI easier for everyone. You can use Teachable Machine to recognize images, sounds or poses.
So in this article, I’m gonna share how you can create your machine learning model using Teachable Machine and integrate in Flutter.
Let’s have a quick look at what we are gonna build today
Class 1 name to
Cat and click on the upload to upload the training images for the cats.
Now do the same for the
Class 2, change the
Class 2 to
Dog and upload the training images for dogs. After uploading the training images, click on the Train Model to start the training.
It’s gonna take time if you have uploaded more number of training images, so sit back and wait for model to get train.
After your model is trained, click on the export model and download the Tensorflow Lite Floating Point Model.
Now it’s time to integrate the .tflite mode in Flutter
Create a new Flutter Project and add
image_picker as a dependency in your
android/app/build.gradle, add the following setting in
assets folder and place your
labels.txt file and
model_unquant.tflite file in
assets folder. In
pubspec.yaml do the following changes to specify files that should be included with the app
import 'package:tflite/tflite.dart'; &
image_picker plugin will be used for picking images from the image library, and taking new pictures with the camera.
After importing libraries, it’s time to load your .tflite model in
main.dart .We will be using a
_loading to show
CircularProgressIndicator while the model is loading.
Now, we will use
image_picker plugin to pick an image from the Gallery whenever the
FloatingActionButton is pressed. The image we pick will be passed as an argument to
classifyImage. We will use
Tflite.runModelOnImage to classify images of dogs and cats.
Now it’s time to display the image we picked and the classification results on the screen.
It’s time to run the Flutter Application. Run
flutter run command in terminal to run your app.
Check out the GitHub Repository for the source code of above application.
Hey Readers, I’m a Mobile Application Developer who loves to explore deep sea of Flutter widgets. If you liked this article and found this helpful don’t forget to appreciate by a 50 claps :p
If you have any questions or suggestions feel free to comment below or you can connect with me on
The latest Tweets from Ayush Bherwani (@ayushbherwani). Organizer @flutterbootcamp | Lead @DSC_PU | Founder @wiz_a_thon…
Ayush Bherwani - PARUL INSTITUTE OF ENGG. AND TECH., LIMDA, VAGHODIA 037 - Vadodara, Gujarat, India…
View Ayush Bherwani's profile on LinkedIn, the world's largest professional community. Ayush has 3 jobs listed on their…
Checkout my recent articles