tensorflow_face_verification 0.1.0
tensorflow_face_verification: ^0.1.0 copied to clipboard
AI Powered Face Verification (Face Embedding & Comparison)
Flutter Face Verification (Face Embedding & Comparison) #
This project provides face verification capabilities using TensorFlow Lite and Google ML Kit Face Detection
via a lightweight helper class built in Dart.
- ๐ง 128D Face Embedding Generation (FaceNet model)
- ๐ ML Kit Face Detection with auto-cropping
- ๐ธ Compare faces and compute similarity score
๐จ The code assumes the use of a tflite model
facenet.tflite.
โ๏ธ Works offline โ all computation is done on-device.
โ Fully asynchronous and customizable.
๐งช Features #
- Match faces between two images
- Detect and crop the face region from an image
- Measure similarity between faces
- Offline use โ no internet required
๐งช Note #
This package is rely on tflite_flutter.
๐จ This package may not work in the iOS simulator. It's recommended that you test with a physical device.
๐จ When creating a release archive (IPA), the symbols are stripped by Xcode, so the command flutter build ipa may throw a Failed to lookup symbol ... symbol not found error. To work around this:
- In Xcode, go to Target Runner > Build Settings > Strip Style
- Change from All Symbols to Non-Global Symbols
๐ Getting Started #
1. Add Your Model #
Place your model in assets/models/facenet.tflite.
flutter:
assets:
- assets/models/facenet.tflite
โ๏ธ Usage Example #
Initialize #
await FaceVerification.init(modelPath: 'assets/models/facenet.tflite');
Compare Two Face Images #
bool isSame = await FaceVerification.instance.verifySamePerson(
File('path/to/image1.jpg'),
File('path/to/image2.jpg'),
threshold: 0.6,
);
print("Same person? $isSame");
Get Similarity Score #
double score = await FaceVerification.instance.getFaceSimilarityFromFile(
File('path/to/image1.jpg'),
File('path/to/image2.jpg'),
);
print("Similarity: $score");
Image image1 = ....;
Image image2 = ....;
double score = await FaceVerification.instance.getFaceSimilarityFromImage(
image1,
image2,
);
print("Similarity: $score");
Additional customizations #
Image image1FaceRegion = await FaceVerification.instance.extractFaceRegion(
File('path/to/image1.jpg')
);
Image image2FaceRegion = await FaceVerification.instance.extractFaceRegion(
File('path/to/image1.jpg')
);
List<double> image1EmbeddingVector = await FaceVerification.instance.extractFaceEmbedding(
image1FaceRegion
);
List<double> image2EmbeddingVector = await FaceVerification.instance.extractFaceEmbedding(
image2FaceRegion
);
double score = await FaceVerification.instance.getSimilarityScore(
image1EmbeddingVector, image2EmbeddingVector
);
print("Similarity: $score");
print("Same person ${score > 0.6}");
๐ค Contributing #
Feel free to fork, modify, and submit a PR.
Suggestions, bug reports, or new features are welcome.
๐ License #
MIT License