|
|
@@ -20,7 +20,10 @@ class _MyAppState extends State<MyApp> {
|
|
|
bool _hasPermission = false;
|
|
|
StreamSubscription<ClassificationEvent?>? _subscription;
|
|
|
ClassificationProgress? _progress;
|
|
|
- ClassificationResult? _result;
|
|
|
+ List<ClassifiedImageGroup> _similarResult = [];
|
|
|
+ List<ClassifiedImage> _peopleResult = [];
|
|
|
+ List<ClassifiedImage> _screenshotResult = [];
|
|
|
+ List<ClassifiedImage> _blurryResult = [];
|
|
|
bool _isClassifying = false;
|
|
|
String _errorMessage = '';
|
|
|
|
|
|
@@ -107,7 +110,7 @@ class _MyAppState extends State<MyApp> {
|
|
|
),
|
|
|
),
|
|
|
],
|
|
|
- if (_result != null && _progress?.isCompleted == true) ...[
|
|
|
+ if (_progress != null) ...[
|
|
|
const SizedBox(height: 20),
|
|
|
const Text('分类结果:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
|
|
_buildResultSummary(),
|
|
|
@@ -128,15 +131,15 @@ class _MyAppState extends State<MyApp> {
|
|
|
}
|
|
|
|
|
|
Widget _buildResultSummary() {
|
|
|
- if (_result == null) return const Text('无结果');
|
|
|
-
|
|
|
+ if (_similarResult.isEmpty && _peopleResult.isEmpty && _screenshotResult.isEmpty && _blurryResult.isEmpty) return const Text('无结果');
|
|
|
+
|
|
|
return Expanded(
|
|
|
child: ListView(
|
|
|
children: [
|
|
|
- _buildResultItem('相似图片组', _result?.similarGroups, isGroup: true),
|
|
|
- _buildResultItem('人物照片', _result?.peopleGroups),
|
|
|
- _buildResultItem('屏幕截图', _result?.screenshotGroups),
|
|
|
- _buildResultItem('模糊图片', _result?.blurryGroups),
|
|
|
+ _buildResultItem('相似图片组', _similarResult.length, isGroup: true),
|
|
|
+ _buildResultItem('人物照片', _peopleResult.length),
|
|
|
+ _buildResultItem('屏幕截图', _screenshotResult.length),
|
|
|
+ _buildResultItem('模糊图片', _blurryResult.length),
|
|
|
],
|
|
|
),
|
|
|
);
|
|
|
@@ -194,7 +197,10 @@ class _MyAppState extends State<MyApp> {
|
|
|
_isClassifying = true;
|
|
|
_errorMessage = '';
|
|
|
_progress = null;
|
|
|
- _result = null;
|
|
|
+ _similarResult = [];
|
|
|
+ _peopleResult = [];
|
|
|
+ _screenshotResult = [];
|
|
|
+ _blurryResult = [];
|
|
|
});
|
|
|
|
|
|
try {
|
|
|
@@ -213,10 +219,16 @@ class _MyAppState extends State<MyApp> {
|
|
|
if (event == null) return;
|
|
|
setState(() {
|
|
|
_progress = event.progress;
|
|
|
- print("批次: ${event.progress?.currentBatch}/${event.progress?.totalBatches}, 进度: ${event.progress?.batchDuration}");
|
|
|
- print("${event.result?.screenshotGroups?.length}");
|
|
|
+ print("批次: ${event.progress?.currentBatch}/${event.progress?.totalBatches}, 用时: ${event.progress?.batchDuration}");
|
|
|
+ print("${event.result?.screenshotImages?.length}");
|
|
|
+ var result = event.result;
|
|
|
+ if (result != null) {
|
|
|
+ _similarResult.addAll(result.similarGroups?.map((group) => group).toList() ?? []);
|
|
|
+ _peopleResult.addAll(result.peopleImages?.map((image) => image).toList() ?? []);
|
|
|
+ _screenshotResult.addAll(result.screenshotImages?.map((image) => image).toList() ?? []);
|
|
|
+ _blurryResult.addAll(result.blurryImages?.map((image) => image).toList() ?? []);
|
|
|
+ }
|
|
|
if (event.progress?.isCompleted == true) {
|
|
|
- _result = event.result;
|
|
|
_isClassifying = false;
|
|
|
_subscription?.cancel();
|
|
|
// 取消订阅
|
|
|
@@ -261,7 +273,10 @@ class _MyAppState extends State<MyApp> {
|
|
|
void _resetAll() {
|
|
|
setState(() {
|
|
|
_progress = null;
|
|
|
- _result = null;
|
|
|
+ _similarResult = [];
|
|
|
+ _peopleResult = [];
|
|
|
+ _screenshotResult = [];
|
|
|
+ _blurryResult = [];
|
|
|
_errorMessage = '';
|
|
|
_isClassifying = false;
|
|
|
});
|