Skip to content

Commit 62811a6

Browse files
cynthiajoangoogle-labs-jules[bot]natebosch
authored
feat(firebaseai): imagen editing (#17556)
* feat: Add support for Imagen editing * some level of working imagen editing * inpaint background change working * some profiling fix * make MessageData hold image bytes instead of Image object * rename toString to toJson * solved the freeze issue with outpainting * restore example main * prepare for review * fix some test error * fix analyzer * more analyzer fix * more more analyzer * update from api review * analyzer * Apply suggestions from code review Co-authored-by: Nate Bosch <nbosch@google.com> * API review update * remove the commented out api * fix the format --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Nate Bosch <nbosch@google.com>
1 parent def807a commit 62811a6

22 files changed

+1319
-67
lines changed

packages/firebase_ai/firebase_ai/example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class _GenerativeAISampleState extends State<GenerativeAISample> {
8181
imageFormat: ImagenFormat.jpeg(compressionQuality: 75),
8282
);
8383
return instance.imagenModel(
84-
model: 'imagen-3.0-generate-002',
84+
model: 'imagen-3.0-capability-001',
8585
generationConfig: generationConfig,
8686
safetySettings: ImagenSafetySettings(
8787
ImagenSafetyFilterLevel.blockLowAndAbove,

packages/firebase_ai/firebase_ai/example/lib/pages/audio_page.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ class _AudioPageState extends State<AudioPage> {
137137
itemBuilder: (context, idx) {
138138
return MessageWidget(
139139
text: _messages[idx].text,
140-
image: _messages[idx].image,
140+
image: Image.memory(
141+
_messages[idx].imageBytes!,
142+
cacheWidth: 400,
143+
cacheHeight: 400,
144+
),
141145
isFromUser: _messages[idx].fromUser ?? false,
142146
);
143147
},

packages/firebase_ai/firebase_ai/example/lib/pages/bidi_page.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ class _BidiPageState extends State<BidiPage> {
133133
itemBuilder: (context, idx) {
134134
return MessageWidget(
135135
text: _messages[idx].text,
136-
image: _messages[idx].image,
136+
image: Image.memory(
137+
_messages[idx].imageBytes!,
138+
cacheWidth: 400,
139+
cacheHeight: 400,
140+
),
137141
isFromUser: _messages[idx].fromUser ?? false,
138142
);
139143
},

packages/firebase_ai/firebase_ai/example/lib/pages/chat_page.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ class _ChatPageState extends State<ChatPage> {
7070
itemBuilder: (context, idx) {
7171
return MessageWidget(
7272
text: _messages[idx].text,
73-
image: _messages[idx].image,
73+
image: Image.memory(
74+
_messages[idx].imageBytes!,
75+
cacheWidth: 400,
76+
cacheHeight: 400,
77+
),
7478
isFromUser: _messages[idx].fromUser ?? false,
7579
);
7680
},

packages/firebase_ai/firebase_ai/example/lib/pages/image_prompt_page.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ class _ImagePromptPageState extends State<ImagePromptPage> {
6565
var content = _generatedContent[idx];
6666
return MessageWidget(
6767
text: content.text,
68-
image: content.image,
68+
image: Image.memory(
69+
content.imageBytes!,
70+
cacheWidth: 400,
71+
cacheHeight: 400,
72+
),
6973
isFromUser: content.fromUser ?? false,
7074
);
7175
},
@@ -137,14 +141,14 @@ class _ImagePromptPageState extends State<ImagePromptPage> {
137141
];
138142
_generatedContent.add(
139143
MessageData(
140-
image: Image.asset('assets/images/cat.jpg'),
144+
imageBytes: catBytes.buffer.asUint8List(),
141145
text: message,
142146
fromUser: true,
143147
),
144148
);
145149
_generatedContent.add(
146150
MessageData(
147-
image: Image.asset('assets/images/scones.jpg'),
151+
imageBytes: sconeBytes.buffer.asUint8List(),
148152
fromUser: true,
149153
),
150154
);

0 commit comments

Comments
 (0)