-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output with predicated score and label #41
Comments
Hi, yes it’s possible to get the raw score. All you need to do is set TfliteAudio.loadModel(
model: 'assets/conv_actions_frozen.tflite',
label: 'assets/conv_actions_label.txt',
inputType: 'decodedWav',
outputRawScores: true, //change value here
numThreads: 1,
isAsset: true,
);
|
You need to get the scores from the stream. Sample code is from the example result = TfliteAudio.startAudioRecognition(
sampleRate: sampleRate,
bufferSize: bufferSize,
numOfInferences: numOfInferences,
);
result
?.listen((event) =>
print("Recognition Result: " + event["recognitionResult"].toString()));
|
Yes, I am using the exact same audio code, but when I set |
Hi, Of course it will not match the labels as you are returning the raw scores. If you use the code that i have pasted above, it should print out the raw score on the terminal. If you wish to match the raw scores to the labels, you'll need to implement the code yourself. For an example of an implementation, please take a the code found here //model initialization
TfliteAudio.loadModel(
inputType: 'rawAudio', //'decodedWav', //'rawAudio',
numThreads: 1,
outputRawScores: true,
isAsset: true,
model:
'assets/cough_model.tflite',
label:
'assets/cough_label.txt'
);
Stream<Map<dynamic, dynamic>>? result;
result = TfliteAudio.startAudioRecognition(
sampleRate: 44100,
//recordingLength: 44032, //16000, //44032,
bufferSize: 11008, //to get 2-3 secs of analisys instead of 1
numOfInferences: 99999,
detectionThreshold: 0.7,
averageWindowDuration: 1500,
//minimumTimeBetweenSamples: this.minimumTimeBetweenSamples,
//suppressionTime: this.suppressionTime,
);
///Logs the results and assigns false when stream is finished.
result.listen((audioEvent) {
var scores = audioEvent['recognitionResult'];
try {
//handle Unexpected character error
scores = jsonDecode(scores.replaceAll('"', ''));
} catch (e) {
Exception(e.toString());
}
double last = 0;
double max = 1;
if (scores is List) {
List<double> l = scores.cast<double>();
last = l.last;
max = l.reduce(math.max);
}
//if cough has the higher percentage and this is higher than 0.72 > IS COUGH
if (last == max && max > 0.72) {
count = count + 1;
FlutterBackgroundService().setNotificationInfo(
title: "Background",
content: "$count",
);
FlutterBackgroundService().sendData(
{"result": count},
);
}
}).onDone(() {}); |
Hi,
@Caldarie can I add the predicted label with score or value as shown in the image below
Can you please help with this, it would be appreciated
The text was updated successfully, but these errors were encountered: