Skip to content
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

chore: update dependencies #80

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Sample app: [Audio Classification](https://github.com/am15h/tflite_flutter_helpe
// Create a container for the result and specify that this is a quantized model.
// Hence, the 'DataType' is defined as UINT8 (8-bit unsigned integer)
TensorBuffer probabilityBuffer =
TensorBuffer.createFixedSize(<int>[1, 1001], TfLiteType.uint8);
TensorBuffer.createFixedSize(<int>[1, 1001], TensorType.uint8);
```

#### Loading the model and running inference:
Expand All @@ -81,7 +81,6 @@ If the model produces a quantized output, remember to convert the result.
For the MobileNet quantized model, the developer needs to divide each output value by 255
to obtain the probability ranging from 0 (least likely) to 1 (most likely) for each category.


### Optional: Mapping results to labels

Developers can also optionally map the results to labels. First, copy the text
Expand Down
1 change: 1 addition & 0 deletions example/audio_classification/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/audio_classification/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
8 changes: 4 additions & 4 deletions example/audio_classification/lib/classifier.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:typed_data';

import 'package:audio_classification/main.dart';
import 'package:flutter/services.dart';
import 'package:collection/collection.dart';
Expand All @@ -15,7 +13,7 @@ class Classifier {

late TensorBuffer _outputBuffer;

TfLiteType _outputType = TfLiteType.uint8;
TensorType _outputType = TensorType.uint8;

final String _modelFileName = 'yamnet.tflite';
final String _labelFileName = 'assets/yamnet_class_map.csv';
Expand Down Expand Up @@ -84,7 +82,9 @@ List<Category> getTopProbability(Map<String, double> labeledProb) {
var pq = PriorityQueue<MapEntry<String, double>>(compare);
pq.addAll(labeledProb.entries);
var result = <Category>[];
while (pq.isNotEmpty && result.length < 5 && (pq.first.value > 0.1 || result.length < 3)) {
while (pq.isNotEmpty &&
result.length < 5 &&
(pq.first.value > 0.1 || result.length < 3)) {
result.add(Category(pq.first.key, pq.first.value));
pq.removeFirst();
}
Expand Down
3 changes: 1 addition & 2 deletions example/audio_classification/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:ui';
import 'package:audio_classification/classifier.dart';
import 'package:flutter/material.dart';
import 'package:random_color/random_color.dart';
Expand Down Expand Up @@ -83,7 +82,7 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(primaryColor: Colors.orange, accentColor: Colors.orange),
theme: ThemeData(primaryColor: Colors.orange),
home: Scaffold(
appBar: AppBar(
title: const Text(
Expand Down
Loading