-
Notifications
You must be signed in to change notification settings - Fork 810
Description
Describe your issue. If applicable, add screenshots to help explain your problem.
How I find the problem:
I have successfully seg pictures with this subject segmentation plugin, and I worked on other pages for several days. Today I try my succeeded-seg-page, but it fails this time.The try-catch throw out the Error like:'Waiting for the subject segmentation optional module to be downloaded.'
I never uninstall the app , change any settings or change the function code of segmentation
The backend shows no use of the Internet, so I can make sure the module is not downloading.
What I have did to fix:
I checked settings, dependencies in build.gradle, (android:value="subject_segment") in AndroidManifest, all correct.
I reload the google_mlkit_subject_segmentation: ^0.0.2 dependencies in pubspec.yaml
I re-install the app after checked settings.
Still failed.
My code:
Future<ImageProvider?> segment(InputImage inputImage) async {
final SubjectSegmenter segmenter = SubjectSegmenter(
options: SubjectSegmenterOptions(
enableForegroundConfidenceMask: false,
enableForegroundBitmap: true,
enableMultipleSubjects: SubjectResultOptions(
enableConfidenceMask: true,
enableSubjectBitmap: true,
),
),
);
try {
final mask = await segmenter.processImage(inputImage);
Get.defaultDialog(title: '1');
if (mask.subjects.isEmpty) {
Get.defaultDialog(title: 'Error', content: Text('No Enetity'));
return null;
}
final Uint8List? data = mask.subjects[0].bitmap;
if (data == null) {
Get.defaultDialog(title: 'Error', content: Text('bitmap is null'));
return null;
}
await saveImageToGallery(data);
return Image.memory(data!).image;
return MemoryImage(data);
} catch (e, stackTrace) {
print('segment function error: $e');
print('stack fail: $stackTrace');
Get.defaultDialog(title: 'Fail', content: Text('Error: $e'));
return null;
} finally {
segmenter.close();
}
}
Steps to reproduce.
Just run the function
What is the expected result?
problem solved
or I can somehow control the model-downloading process
Did you try our example app?
Yes
Is it reproducible in the example app?
No
Reproducible in which OS?
Android
Flutter/Dart Version?
No response
Plugin Version?
google_mlkit_subject_segmentation: ^0.0.2