investigating why the input to the model is incorrect resulting in error on initialization.
This commit is contained in:
+36
-1
@@ -2,6 +2,9 @@ import 'dart:isolate';
|
||||
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tensordex_mobile/tflite/classifier.dart';
|
||||
import 'package:tflite_flutter/tflite_flutter.dart';
|
||||
import 'package:tensordex_mobile/utils/image_utils.dart';
|
||||
|
||||
import '../utils/logger.dart';
|
||||
import '../utils/recognition.dart';
|
||||
@@ -30,10 +33,13 @@ class _CameraViewState extends State<CameraView> with WidgetsBindingObserver {
|
||||
|
||||
/// Controller
|
||||
late CameraController cameraController;
|
||||
Interpreter? interp;
|
||||
|
||||
/// true when inference is ongoing
|
||||
bool predicting = false;
|
||||
|
||||
late Classifier classy;
|
||||
|
||||
// /// Instance of [Classifier]
|
||||
// Classifier classifier;
|
||||
//
|
||||
@@ -56,9 +62,28 @@ class _CameraViewState extends State<CameraView> with WidgetsBindingObserver {
|
||||
// Camera initialization
|
||||
initializeCamera();
|
||||
|
||||
// final gpuDelegateV2 = GpuDelegateV2(
|
||||
// options: GpuDelegateOptionsV2(
|
||||
// isPrecisionLossAllowed: false,
|
||||
// inferencePreference: TfLiteGpuInferenceUsage.fastSingleAnswer,
|
||||
// inferencePriority1: TfLiteGpuInferencePriority.minLatency,
|
||||
// inferencePriority2: TfLiteGpuInferencePriority.auto,
|
||||
// inferencePriority3: TfLiteGpuInferencePriority.auto,
|
||||
// ));
|
||||
|
||||
|
||||
logger.e("CREATING THE INTERPRETOR");
|
||||
var interpreterOptions = InterpreterOptions();//..addDelegate(gpuDelegateV2);
|
||||
interp = await Interpreter.fromAsset('efficientnet_v2s.tflite',
|
||||
options: interpreterOptions);
|
||||
logger.e("CREATING THE INTERPRETOR");
|
||||
|
||||
classy = Classifier(interpreter: interp);
|
||||
logger.i(interp?.getOutputTensors());
|
||||
// Create an instance of classifier to load model and labels
|
||||
// classifier = Classifier();
|
||||
|
||||
|
||||
// Initially predicting = false
|
||||
predicting = false;
|
||||
}
|
||||
@@ -94,7 +119,7 @@ class _CameraViewState extends State<CameraView> with WidgetsBindingObserver {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Return empty container while the camera is not initialized
|
||||
if (!cameraController.value.isInitialized || cameraController == null) {
|
||||
if (!cameraController.value.isInitialized) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
@@ -114,6 +139,16 @@ class _CameraViewState extends State<CameraView> with WidgetsBindingObserver {
|
||||
predicting = true;
|
||||
});
|
||||
logger.i("RECIEVED IMAGE");
|
||||
logger.i(cameraImage.format.group);
|
||||
logger.i(cameraImage);
|
||||
var converted = ImageUtils.convertCameraImage(cameraImage);
|
||||
if (converted != null){
|
||||
|
||||
var result = classy.predict(converted);
|
||||
|
||||
logger.e("PREDICTED IMAGE");
|
||||
logger.i(result);
|
||||
}
|
||||
// logger.i(cameraImage);
|
||||
// logger.i(cameraImage.height);
|
||||
// logger.i(cameraImage.width);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tensordex_mobile/ui/poke_view.dart';
|
||||
import 'package:tensordex_mobile/utils/recognition.dart';
|
||||
|
||||
import '../utils/logger.dart';
|
||||
|
||||
/// [CameraView] sends each frame for inference
|
||||
class ResultsView extends StatefulWidget {
|
||||
|
||||
/// Constructor
|
||||
const ResultsView({Key? key}) : super(key: key);
|
||||
|
||||
|
||||
void setResults(Recognition results){
|
||||
logger.i("RESULTS IN THE RESULT VIEW");
|
||||
}
|
||||
|
||||
@override
|
||||
State<ResultsView> createState() => _ResultsViewState();
|
||||
}
|
||||
|
||||
class _ResultsViewState extends State<ResultsView> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text("data");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:tensordex_mobile/ui/poke_view.dart';
|
||||
import 'package:tensordex_mobile/ui/results_view.dart';
|
||||
|
||||
import '../utils/logger.dart';
|
||||
import '../utils/recognition.dart';
|
||||
@@ -25,7 +25,6 @@ class TensordexHome extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TensordexHomeState extends State<TensordexHome> {
|
||||
int _counter = 0;
|
||||
|
||||
/// Results to draw bounding boxes
|
||||
List<Recognition>? results;
|
||||
@@ -38,7 +37,6 @@ class _TensordexHomeState extends State<TensordexHome> {
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
_counter++;
|
||||
logger.d("Counter Incremented!");
|
||||
logger.w("Counter Incremented!");
|
||||
logger.e("Counter Incremented!");
|
||||
@@ -129,8 +127,6 @@ class _TensordexHomeState extends State<TensordexHome> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// controller.dispose();
|
||||
// WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -158,17 +154,10 @@ class _TensordexHomeState extends State<TensordexHome> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
CameraView(
|
||||
resultsCallback: resultsCallback,
|
||||
statsCallback: statsCallback
|
||||
),
|
||||
statsCallback: statsCallback),
|
||||
const ResultsView(),
|
||||
],
|
||||
),
|
||||
),
|
||||
Reference in New Issue
Block a user