Skip to content

Commit

Permalink
Add generative background replace action
Browse files Browse the repository at this point in the history
  • Loading branch information
adimiz1 authored Aug 4, 2024
1 parent c530e61 commit c31de57
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions url_gen/lib/transformation/effect/effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
16 changes: 16 additions & 0 deletions url_gen/lib/transformation/effect/effect_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions url_gen/test/transformation/effect_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
Expand Down

0 comments on commit c31de57

Please sign in to comment.