Commit 5689a9bd authored by Dasun Madushanka's avatar Dasun Madushanka

Update main.dart

parent 8fe5de91
//import main packeges
//image picker package for take a picture from gallery and tflite package to detect the image and read the assest file
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:tflite/tflite.dart';
//to run hotstart
void main() => runApp(MaterialApp(
home: MyApp(),
));
......@@ -13,6 +17,7 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
//variables
List _outputs;
File _image;
bool _loading = false;
......@@ -69,6 +74,8 @@ class _MyAppState extends State<MyApp> {
),
);
}
//function for image picker
pickImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
......@@ -80,6 +87,7 @@ class _MyAppState extends State<MyApp> {
classifyImage(image);
}
//detect the image and compare the image with the model
classifyImage(File image) async {
var output = await Tflite.runModelOnImage(
path: image.path,
......@@ -93,14 +101,14 @@ class _MyAppState extends State<MyApp> {
_outputs = output;
});
}
//load the model from assest folder.
loadModel() async {
await Tflite.loadModel(
model: "assets/model_unquant.tflite",
labels: "assets/labels.txt",
);
}
//dispose the model menu
@override
void dispose() {
Tflite.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment