ai_image_classifier 1.0.0
ai_image_classifier: ^1.0.0 copied to clipboard
A simple and powerful Flutter package for on-device image classification using TensorFlow Lite models. Supports custom models, image resizing, and normalization.
<<<<<<< HEAD
AI Image Classifier #
A Flutter package for easy on-device image classification using TensorFlow Lite models.
Features #
- 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.
Getting Started #
1. Add Dependencies #
Add ai_image_classifier to your pubspec.yaml:
dependencies:
ai_image_classifier:
git:
url: https://github.com/swetakothari16/ai_image_classifier.git
2. Add Model and Labels #
Place your .tflite model and labels.txt in your assets folder and register them:
flutter:
assets:
- assets/models/mobilenet_v1.tflite
- assets/models/labels.txt
3. Usage #
import '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();
How to get a sample model? #
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.
License #
MIT #
ai_image_classifier #
45b5afbb9e165e764d9172268b8f7b3279e80ff5