<<<<<<< HEAD
A Flutter package for easy on-device image classification using TensorFlow Lite models.
- Load TFLite models from assets.
- Classify images from bytes or file paths.
- Automatic image preprocessing (resizing and normalization).
- Works with common classification models like MobileNet, ResNet, etc.
Add ai_image_classifier to your pubspec.yaml:
dependencies:
ai_image_classifier:
git:
url: https://github.com/swetakothari16/ai_image_classifier.gitPlace your .tflite model and labels.txt in your assets folder and register them:
flutter:
assets:
- assets/models/mobilenet_v1.tflite
- assets/models/labels.txtimport 'package:ai_image_classifier/ai_image_classifier.dart';
final classifier = AiImageClassifier();
// Load model
await classifier.loadModel(
modelPath: 'assets/models/mobilenet_v1.tflite',
labelsPath: 'assets/models/labels.txt',
);
// Classify image from path
List<Classification> results = await classifier.classifyImagePath(imagePath);
// Print results
for (var res in results) {
print("${res.label}: ${(res.confidence * 100).toStringAsFixed(1)}%");
}
// Dispose when done
classifier.dispose();You can download a pre-trained MobileNet model from TensorFlow Hub:
- Go to TensorFlow Hub MobileNet.
- Download the
.tflitefile. - Use the ImageNet labels provided in the example app's
labels.txt.
45b5afbb9e165e764d9172268b8f7b3279e80ff5