A Flutter application demonstrating how to implement image labeling using the Google ML Kit Image Labeling package. Users can either pick an image from the gallery or capture an image using the camera, and the app will label the image using machine learning.
- 📸 Pick or Capture Image: Pick an image from the gallery or capture one using the camera.
- 🔖 Image Labeling: Leverage Google ML Kit to label objects in images.
- 📊 Confidence Scores: Each label comes with a confidence score.
- 📜 Customizable Confidence Threshold: Set confidence threshold to filter results.
- Flutter SDK (Ensure you have the latest stable Flutter SDK installed)
- Android Studio / Xcode (for Android and iOS development)
- Google ML Kit Image Labeling package
- Add the following dependencies to your
pubspec.yaml
dependencies:
flutter:
sdk: flutter
google_mlkit_image_labeling: ^latest_version
image_picker: ^latest_version
- Run
flutter pub get
to install the dependencies.
- Update the minimum Android SDK requirements in
android/app/build.gradle
android {
compileSdkVersion 34
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
}
}
- Add the required permissions in
android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- Add the following permissions to
ios/Runner/Info.plist
:
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to select images.</string>
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to capture images.</string>
-
Image Labeling:
- Pick or capture an image using the built-in
ImagePickerHelper
- Pass the selected image to the
ImageLabelingHelper
to process and label the image.
- Pick or capture an image using the built-in
-
Reference this Flutter Image Picker Guide if you're unfamiliar with image selection or capture in Flutter.
lib/
├── app.dart # Main entry point for the app
├── home_page.dart # Home page UI for displaying picked or captured image and labels
├── image_labeling_helper.dart # Helper class for image labeling functionality
├── image_picker_helper.dart # Helper class for image selection and capture
└── main.dart # App initialization and camera setup
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
"مَن غَدَا إلى المَسْجِدِ ورَاحَ، أعَدَّ اللَّهُ له نُزُلَهُ مِنَ الجَنَّةِ كُلَّما غَدَا أوْ رَاحَ." صحيح البخاري