commit 02a1489c1539affce3b151f7c0ffe2690ff187c7
parent 15f6cf08c82f3cf9ce761d52ec832e935e3cfdae
Author: maydayv7 <maydayv7@gmail.com>
Date: Wed, 3 Dec 2025 05:41:29 +0530
Minor optimization for image captioning
Diffstat:
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/lib/services/flask_service.dart b/lib/services/flask_service.dart
@@ -44,11 +44,12 @@ class FlaskService {
required String sketchPath,
required String userPrompt,
String? stylePrompt,
+ String? imageDescription,
}) async {
debugPrint("🔗 [Pipeline] Starting Sketch-to-Image...");
- // 1. Analyze Sketch
- final String? sketchDescription = await describeImage(
+ // 1. Analyze Sketch (Use cached description if available)
+ final String? sketchDescription = imageDescription ?? await describeImage(
imagePath: sketchPath,
prompt: '<MORE_DETAILED_CAPTION>',
);
@@ -168,11 +169,12 @@ class FlaskService {
required String userPrompt,
String? stylePrompt,
required int option,
+ String? imageDescription,
}) async {
debugPrint("🔗 [Pipeline] Starting Sketch-to-Image-API...");
- // 1. Analyze Sketch
- final String? sketchDescription = await describeImage(
+ // 1. Analyze Sketch (Use cached description if available)
+ final String? sketchDescription = imageDescription ?? await describeImage(
imagePath: sketchPath,
prompt: '<MORE_DETAILED_CAPTION>',
);
diff --git a/lib/ui/pages/canvas_board_page.dart b/lib/ui/pages/canvas_board_page.dart
@@ -1502,6 +1502,7 @@ class _CanvasBoardPageState extends State<CanvasBoardPage> {
sketchPath: _tempBaseImage!.path,
userPrompt: prompt,
stylePrompt: "high quality, realistic",
+ imageDescription: _aiDescription,
);
}
else if(modelId == 'sketch_advanced'){
@@ -1510,7 +1511,8 @@ class _CanvasBoardPageState extends State<CanvasBoardPage> {
sketchPath: _tempBaseImage!.path,
userPrompt: prompt,
stylePrompt: "high quality, realistic",
- option:1 ,
+ option: 1,
+ imageDescription: _aiDescription,
);
}
@@ -1521,12 +1523,16 @@ class _CanvasBoardPageState extends State<CanvasBoardPage> {
userPrompt: prompt,
stylePrompt: "high quality, realistic",
option: 2,
+ imageDescription: _aiDescription,
);
}
}
if (newImageUrl != null) {
_addGeneratedImage(newImageUrl);
+ setState(() {
+ _isMagicDrawActive = false;
+ });
}
} catch (e) {
debugPrint("Generation Error: $e");