Pristine Checkerは、TensorFlow Liteを使用したリアルタイム欠陥検出モバイルアプリケーションです。カメラを使用して製品の品質をAIで分析し、欠陥の有無を即座に判定します。
- メインエントリーポイント:
lib/main.dart- Flutterアプリのメイン構造 - TensorFlow Liteモデル:
assets/models/model_unquant.tflite- 欠陥検出用のMLモデル - モデルラベル:
assets/models/labels.txt- 分類ラベル(0: Good, 1: Defect) - 依存関係:
pubspec.yaml- Flutter依存関係とアセット設定 - Android設定:
android/app/src/main/AndroidManifest.xml- Android権限と設定 - iOS設定:
ios/Runner/Info.plist- iOS権限と設定
pristine_checker/
├── lib/
│ └── main.dart # メインアプリケーション
├── assets/
│ └── models/
│ ├── model_unquant.tflite # TensorFlow Liteモデル
│ └── labels.txt # 分類ラベル
├── android/ # Android固有の設定
├── ios/ # iOS固有の設定
└── pubspec.yaml # 依存関係とアセット設定
- Flutter: クロスプラットフォームモバイル開発フレームワーク
- Dart: Flutterのプログラミング言語
- camera:
^0.10.5+9- カメラ機能の実装 - permission_handler:
^11.3.1- プラットフォーム間の権限管理 - tflite_flutter:
^0.11.0- TensorFlow Liteモデルの実行
- TensorFlow Lite: モバイル最適化された機械学習フレームワーク
- リアルタイム推論: カメラストリームからの連続的な画像分析
- カメラを使用したライブ画像分析
- 224x224ピクセルにリサイズしてモデルに送信
- BGRA8888フォーマットからRGBへの変換
- [-1, 1]範囲での正規化
- Good: 欠陥なし(緑色表示)
- Defect: 欠陥あり(赤色表示)
- Waiting for object: 背景検出時(青色表示)
- パーセンテージでの信頼度表示
- Softmax関数による確率計算
- 背景検出のための閾値処理
- カメラ権限の動的リクエスト
- 設定画面への誘導
- アプリ再開時の権限状態確認
- Flutter SDK 3.8.1以上
- Android Studio / Xcode
- 物理デバイス(カメラ機能のテスト用)
- リポジトリのクローン
git clone <repository-url>
cd pristine_checker- 依存関係のインストール
flutter pub get- アセットの確認
# モデルファイルとラベルファイルが存在することを確認
ls assets/models/- アプリの実行
# Android
flutter run
# iOS
flutter run -d ios- 入力: 224x224x3 (RGB画像)
- 出力: 2クラス分類 (Good/Defect)
- フォーマット: 非量子化モデル (.tflite)
- 正規化: [-1, 1]範囲
- 画像取得: カメラからBGRA8888フォーマットで取得
- フォーマット変換: BGRA → RGB変換
- リサイズ: 224x224ピクセルにリサイズ
- 正規化: [0, 255] → [-1, 1]範囲に変換
- 推論実行: TensorFlow Liteインタープリターで実行
- Softmax適用: 生のロジットを確率に変換
- 信頼度計算: 各クラスの確率を計算
- 背景検出: 信頼度差と最大信頼度による判定
- UI更新: 結果に基づく色とテキストの更新
- スロットリング: 300ms間隔での処理制限
- 並行処理防止:
_isProcessingフラグによる制御 - メモリ効率: Float32Listの直接使用
- 安定化処理: 400msの待機時間による結果安定化
- 背景検出: 信頼度差0.2未満で背景と判定
- リアルタイム更新: setStateによる即座のUI更新
<!-- AndroidManifest.xml -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" /><!-- Info.plist -->
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to detect defects in products using AI analysis.</string>-
カメラ権限エラー
- 設定アプリでカメラ権限を手動で有効化
- アプリの再起動
-
モデル読み込みエラー
assets/models/フォルダの存在確認pubspec.yamlのアセット設定確認
-
推論エラー
- デバイスのメモリ不足
- モデルファイルの破損
- コンソールログで詳細な処理状況を確認
flutter analyzeでコード品質チェック- 物理デバイスでのテスト推奨
- Flutter Lintsルールに準拠
- 適切なエラーハンドリング
- 非同期処理の適切な実装
- 物理デバイスでの動作確認
- 異なる照明条件でのテスト
- 様々な製品タイプでの検証
このプロジェクトはプライベートプロジェクトです。
プロジェクトへの貢献については、プロジェクトオーナーにお問い合わせください。
Pristine Checker is a real-time defect detection mobile application using TensorFlow Lite. It analyzes product quality using AI through the camera and instantly determines the presence of defects.
- Main Entry Point:
lib/main.dart- Main Flutter app structure - TensorFlow Lite Model:
assets/models/model_unquant.tflite- ML model for defect detection - Model Labels:
assets/models/labels.txt- Classification labels (0: Good, 1: Defect) - Dependencies:
pubspec.yaml- Flutter dependencies and asset configuration - Android Config:
android/app/src/main/AndroidManifest.xml- Android permissions and configuration - iOS Config:
ios/Runner/Info.plist- iOS permissions and configuration
pristine_checker/
├── lib/
│ └── main.dart # Main application
├── assets/
│ └── models/
│ ├── model_unquant.tflite # TensorFlow Lite model
│ └── labels.txt # Classification labels
├── android/ # Android-specific configuration
├── ios/ # iOS-specific configuration
└── pubspec.yaml # Dependencies and asset configuration
- Flutter: Cross-platform mobile development framework
- Dart: Programming language for Flutter
- camera:
^0.10.5+9- Camera functionality implementation - permission_handler:
^11.3.1- Cross-platform permission management - tflite_flutter:
^0.11.0- TensorFlow Lite model execution
- TensorFlow Lite: Mobile-optimized machine learning framework
- Real-time Inference: Continuous image analysis from camera stream
- Live image analysis using camera
- Resize to 224x224 pixels for model input
- BGRA8888 to RGB format conversion
- Normalization to [-1, 1] range
- Good: No defects (green display)
- Defect: Defects present (red display)
- Waiting for object: Background detected (blue display)
- Percentage-based confidence display
- Probability calculation using Softmax function
- Threshold processing for background detection
- Dynamic camera permission requests
- Settings navigation guidance
- Permission status check on app resume
- Flutter SDK 3.8.1 or higher
- Android Studio / Xcode
- Physical device (for camera functionality testing)
- Clone Repository
git clone <repository-url>
cd pristine_checker- Install Dependencies
flutter pub get- Verify Assets
# Confirm model and label files exist
ls assets/models/- Run Application
# Android
flutter run
# iOS
flutter run -d ios- Input: 224x224x3 (RGB image)
- Output: 2-class classification (Good/Defect)
- Format: Unquantized model (.tflite)
- Normalization: [-1, 1] range
- Image Capture: Acquire BGRA8888 format from camera
- Format Conversion: BGRA → RGB conversion
- Resize: Resize to 224x224 pixels
- Normalization: Convert [0, 255] → [-1, 1] range
- Inference Execution: Execute using TensorFlow Lite interpreter
- Softmax Application: Convert raw logits to probabilities
- Confidence Calculation: Calculate probability for each class
- Background Detection: Determine based on confidence difference and maximum confidence
- UI Update: Update colors and text based on results
- Throttling: 300ms interval processing limitation
- Concurrent Processing Prevention: Control using
_isProcessingflag - Memory Efficiency: Direct use of Float32List
- Stabilization Processing: Result stabilization with 400ms wait time
- Background Detection: Determine background when confidence difference < 0.2
- Real-time Updates: Immediate UI updates via setState
<!-- AndroidManifest.xml -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" /><!-- Info.plist -->
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to detect defects in products using AI analysis.</string>-
Camera Permission Error
- Manually enable camera permission in Settings app
- Restart the application
-
Model Loading Error
- Verify existence of
assets/models/folder - Check asset configuration in
pubspec.yaml
- Verify existence of
-
Inference Error
- Device memory shortage
- Model file corruption
- Check detailed processing status via console logs
- Use
flutter analyzefor code quality check - Test on physical devices recommended
- Comply with Flutter Lints rules
- Proper error handling
- Appropriate async processing implementation
- Verify operation on physical devices
- Test under different lighting conditions
- Validate with various product types
This project is a private project.
For contributions to this project, please contact the project owner.