Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for upscale effect #16

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Transformation/Effect/Generative/GenerativeEffect.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ abstract class GenerativeEffect
{
const GENERATIVE_RECOLOR = 'gen_recolor';
const GENERATIVE_REMOVE = 'gen_remove';
const GENERATIVE_REPLACE = 'gen_replace';
const GENERATIVE_RESTORE = 'gen_restore';
const GENERATIVE_REPLACE = 'gen_replace';
const GENERATIVE_RESTORE = 'gen_restore';
const UPSCALE = 'upscale';

use GenerativeEffectTrait;
}
11 changes: 11 additions & 0 deletions src/Transformation/Effect/Generative/GenerativeEffectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,15 @@ public static function generativeReplace($fromPrompt, $toPrompt, $preserveGeomet
{
return new GenerativeReplace($fromPrompt, $toPrompt, $preserveGeometry, $detectMultiple);
}

/**
* Uses AI-based prediction to add fine detail while upscaling small images.
* This 'super-resolution' feature scales each dimension by four, multiplying the total number of pixels by 16.
*
* @return GenerativeEffectAction
*/
public static function upscale()
{
return new GenerativeEffectAction(GenerativeEffect::UPSCALE);
}
}
8 changes: 8 additions & 0 deletions tests/Unit/Transformation/Image/GenerativeEffectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@ public function testGenerativeReplace()
(string)Effect::generativeReplace('balloon', 'airplane')->preserveGeometry(false)->detectMultiple()
);
}

public function testGenerativeUpscale()
{
self::assertEquals(
'e_upscale',
(string)Effect::upscale()
);
}
}
Loading