-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update comment and clear out few things
- Loading branch information
1 parent
fa406f2
commit df0e188
Showing
6 changed files
with
145 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. | ||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
TODO: Add your license here. | ||
MIT License | ||
|
||
Copyright (c) 2022 Francisco Bernal, Bharat Biradar and Benson Arafat. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,96 @@ | ||
# google_mlkit_subjection_segmentation | ||
# Google's ML Kit Subject Segmentation for Flutter | ||
|
||
A new Flutter plugin project. | ||
[](https://pub.dev/packages/google_mlkit_subject_segmentation) | ||
[](https://github.com/flutter-ml/google_ml_kit_flutter/actions) | ||
[](https://github.com/flutter-ml/google_ml_kit_flutter) | ||
[](https://opensource.org/licenses/MIT) | ||
|
||
## Getting Started | ||
> ***NOTE: This feature is still in Beta, and it is only available for Android. Stay tune for updates in [Google's website](https://developers.google.com/ml-kit/vision/subject-segmentation) and request the feature [here](https://github.com/googlesamples/mlkit/issues).*** | ||
This project is a starting point for a Flutter | ||
[plug-in package](https://flutter.dev/developing-packages/), | ||
a specialized package that includes platform-specific implementation code for | ||
Android and/or iOS. | ||
A Flutter plugin to use [Google's ML Kit Subject Segmentation](https://developers.google.com/ml-kit/vision/subject-segmentation) to easily separate multiple subjects from the background in a picture, enabling use cases such as sticker creation, background swap, or adding cool effects to subjects. | ||
|
||
For help getting started with Flutter development, view the | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
Subjects are defined as the most prominent people, pets, or objects in the foreground of the image. If 2 subjects are very close or touching each other, they are considered a single subject. | ||
|
||
Each pixel of the mask is assigned a float number that has a range between 0.0 and 1.0. The closer the number is to 1.0, the higher the confidence that the pixel represents a subject, and vice versa | ||
|
||
On average the latency measured on Pixel 7 Pro is around 200 ms. This API currently only supports static images. | ||
|
||
Key capabilities | ||
|
||
- Multi-subject segmentation: provides masks and bitmaps for each individual subject, rather than a single mask and bitmap for all subjects combined. | ||
- Subject recognition: subjects recognized are objects, pets, and humans. | ||
- On-device processing: all processing is performed on the device, preserving user privacy and requiring no network connectivity. | ||
|
||
|
||
**PLEASE READ THIS** before continuing or posting a [new issue](https://github.com/flutter-ml/google_ml_kit_flutter/issues): | ||
|
||
- [Google's ML Kit](https://developers.google.com/ml-kit) was build only for mobile platforms: iOS and Android apps. Web or any other platform is not supported, you can request support for those platform to Google in [their repo](https://github.com/googlesamples/mlkit/issues). | ||
|
||
- This plugin is not sponsored or maintained by Google. The [authors](https://github.com/flutter-ml/google_ml_kit_flutter/blob/master/AUTHORS) are developers excited about Machine Learning that wanted to expose Google's native APIs to Flutter. | ||
|
||
- Google's ML Kit APIs are only developed natively for iOS and Android. This plugin uses Flutter Platform Channels as explained [here](https://docs.flutter.dev/development/platform-integration/platform-channels). | ||
|
||
Messages are passed between the client (the app/plugin) and host (platform) using platform channels as illustrated in this diagram: | ||
|
||
<p align="center" width="100%"> | ||
<img src="https://docs.flutter.dev/assets/images/docs/PlatformChannels.png"> | ||
</p> | ||
|
||
Messages and responses are passed asynchronously, to ensure the user interface remains responsive. To read more about platform channels go [here](https://docs.flutter.dev/development/platform-integration/platform-channels). | ||
|
||
Because this plugin uses platform channels, no Machine Learning processing is done in Flutter/Dart, all the calls are passed to the native platform using `MethodChannel` in Android and `FlutterMethodChannel` in iOS, and executed using Google's native APIs. Think of this plugin as a bridge between your app and Google's native ML Kit APIs. This plugin only passes the call to the native API and the processing is done by Google's API. It is important that you understand this concept when it comes to debugging errors for your ML model and/or app. | ||
|
||
- Since the plugin uses platform channels, you may encounter issues with the native API. Before submitting a new issue, identify the source of the issue. You can run both iOS and/or Android native [example apps by Google](https://github.com/googlesamples/mlkit) and make sure that the issue is not reproducible with their native examples. If you can reproduce the issue in their apps then report the issue to Google. The [authors](https://github.com/flutter-ml/google_ml_kit_flutter/blob/master/AUTHORS) do not have access to the source code of their native APIs, so you need to report the issue to them. If you find that their example apps are okay and still you have an issue using this plugin, then look at our [closed and open issues](https://github.com/flutter-ml/google_ml_kit_flutter/issues). If you cannot find anything that can help you then report the issue and provide enough details. Be patient, someone from the community will eventually help you. | ||
|
||
## Requirements | ||
|
||
### iOS | ||
|
||
This feature is still in Beta, and it is only available for Android. Stay tune for updates in [Google's website](https://developers.google.com/ml-kit/vision/subject-segmentation) and request the feature [here](https://github.com/googlesamples/mlkit/issues). | ||
|
||
### Android | ||
|
||
- minSdkVersion: 24 | ||
- targetSdkVersion: 33 | ||
- compileSdkVersion: 34 | ||
|
||
## Usage | ||
|
||
### Subject Segmentation | ||
|
||
#### Create an instance of `InputImage` | ||
|
||
Create an instance of `InputImage` as explained [here](https://github.com/flutter-ml/google_ml_kit_flutter/blob/master/packages/google_mlkit_commons#creating-an-inputimage). | ||
|
||
```dart | ||
final InputImage inputImage; | ||
``` | ||
|
||
#### Create an instance of `SubjectSegmenter` | ||
|
||
```dart | ||
final segmenter = SubjectSegmenter(); | ||
``` | ||
|
||
#### Process image | ||
|
||
```dart | ||
final mask = await segmenter.processImage(inputImage); | ||
``` | ||
|
||
#### Release resources with `close()` | ||
|
||
```dart | ||
segmenter.close(); | ||
``` | ||
|
||
## Example app | ||
|
||
Find the example app [here](https://github.com/flutter-ml/google_ml_kit_flutter/tree/master/packages/example). | ||
|
||
## Contributing | ||
|
||
Contributions are welcome. | ||
In case of any problems look at [existing issues](https://github.com/flutter-ml/google_ml_kit_flutter/issues), if you cannot find anything related to your problem then open an issue. | ||
Create an issue before opening a [pull request](https://github.com/flutter-ml/google_ml_kit_flutter/pulls) for non trivial fixes. | ||
In case of trivial fixes open a [pull request](https://github.com/flutter-ml/google_ml_kit_flutter/pulls) directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters