From c31de577ed116cb2dfb634f919bb955f81d6df55 Mon Sep 17 00:00:00 2001 From: adimiz1 <95848801+adimiz1@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:00:26 +0300 Subject: [PATCH] Add generative background replace action --- url_gen/lib/transformation/effect/effect.dart | 4 ++++ .../transformation/effect/effect_actions.dart | 16 ++++++++++++++++ url_gen/test/transformation/effect_test.dart | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/url_gen/lib/transformation/effect/effect.dart b/url_gen/lib/transformation/effect/effect.dart index c40c7ee..7b5aae6 100644 --- a/url_gen/lib/transformation/effect/effect.dart +++ b/url_gen/lib/transformation/effect/effect.dart @@ -306,6 +306,10 @@ class Effect extends Action { return GenerativeRestore(); } + static GenerativeBackgroundReplace generativeBackgroundReplace({String? prompt}) { + return GenerativeBackgroundReplace(prompt); + } + static BlurFaces blurFaces({dynamic strength}) { return BlurFaces(strength: strength); } diff --git a/url_gen/lib/transformation/effect/effect_actions.dart b/url_gen/lib/transformation/effect/effect_actions.dart index cd941b3..2f65d2e 100644 --- a/url_gen/lib/transformation/effect/effect_actions.dart +++ b/url_gen/lib/transformation/effect/effect_actions.dart @@ -1073,6 +1073,22 @@ class GenerativeRestore extends Effect { } } +class GenerativeBackgroundReplace extends Effect { + String? _prompt; + + GenerativeBackgroundReplace(this._prompt); + + GenerativeBackgroundReplace prompt(String prompt) { + _prompt = prompt; + return this; + } + + @override + String toString() { + return super.toString().joinWithValues(['gen_background_replace'], actionSeparator: paramKeyValueSeparator).joinWithValues([_prompt != null ? 'prompt_$_prompt' : null]); + } +} + class BlurRegion extends Effect { dynamic _strength; diff --git a/url_gen/test/transformation/effect_test.dart b/url_gen/test/transformation/effect_test.dart index 182b8cb..f10a7dd 100644 --- a/url_gen/test/transformation/effect_test.dart +++ b/url_gen/test/transformation/effect_test.dart @@ -345,6 +345,11 @@ void main() { cldAssert('e_gen_restore', Effect.generativeRestore()); }); + test('Test successful generative background replace effect', () { + cldAssert('e_gen_background_replace', Effect.generativeBackgroundReplace()); + cldAssert('e_gen_background_replace:prompt_dog', Effect.generativeBackgroundReplace(prompt: 'dog')); + }); + test('Test successful upscale effect', () { cldAssert('e_upscale', Effect.upscale()); });