diff --git a/Classes/Backend/Hooks/ButtonBarHook.php b/Classes/Backend/Hooks/ButtonBarHook.php index f3f87c0..a2c797c 100644 --- a/Classes/Backend/Hooks/ButtonBarHook.php +++ b/Classes/Backend/Hooks/ButtonBarHook.php @@ -50,6 +50,8 @@ public function getButtons(array $params, ButtonBar $buttonBar) return $buttons; } + + return $buttons; } public function buildUriToControllerAction(): string diff --git a/Classes/Http/Client/OpenAiClient.php b/Classes/Http/Client/OpenAiClient.php index 31c4e5f..fad5db1 100644 --- a/Classes/Http/Client/OpenAiClient.php +++ b/Classes/Http/Client/OpenAiClient.php @@ -33,15 +33,20 @@ public function image(string $text): array { $openAi = new OpenAi($this->getApiKey()); - $array = [ - 'prompt' => $text, - 'n' => 2, - 'size' => '256x256', - ]; - - $response = $this->validateResponse($openAi->image($array)); - - $images = $this->responseToImages($response); + $images = []; + for ($i = 0; $i < 3; ++$i) { + $array = [ + 'model' => 'dall-e-3', + 'prompt' => $text, + 'n' => 1, + 'size' => '1024x1024', + ]; + + $response = $this->validateResponse($openAi->image($array)); + + $tempImages = $this->responseToImages($response); + $images = array_merge($images, $tempImages); + } return $images; } diff --git a/Classes/Http/Client/StabilityAiClient.php b/Classes/Http/Client/StabilityAiClient.php index f7a80ad..bdaaec4 100644 --- a/Classes/Http/Client/StabilityAiClient.php +++ b/Classes/Http/Client/StabilityAiClient.php @@ -94,15 +94,15 @@ public function image(string $text): array ], 'cfg_scale' => 7, 'clip_guidance_preset' => 'FAST_BLUE', - 'height' => 512, - 'width' => 512, - 'samples' => 2, + 'height' => 1024, + 'width' => 1024, + 'samples' => 3, 'steps' => 30, ]; $response = $this->client->request( 'POST', - $this->getEndpointLink('v1/generation/stable-diffusion-512-v2-1/text-to-image'), + $this->getEndpointLink('v1/generation/stable-diffusion-xl-1024-v1-0/text-to-image'), [ 'headers' => $headers, 'body' => json_encode($params), @@ -130,7 +130,7 @@ public function createImageVariation(File $file): array 'text_prompts[0][text]' => 'variant of original image', 'cfg_scale' => '7', 'clip_guidance_preset' => 'FAST_BLUE', - 'samples' => '1', + 'samples' => '3', 'steps' => '30', ]); @@ -139,7 +139,7 @@ public function createImageVariation(File $file): array $response = $this->client->request( 'POST', - $this->getEndpointLink('v1/generation/stable-diffusion-512-v2-1/image-to-image'), + $this->getEndpointLink('v1/generation/stable-diffusion-xl-1024-v1-0/image-to-image'), [ 'headers' => $headers, 'body' => $formData->bodyToIterable(), diff --git a/README.md b/README.md index aa1c7eb..08beded 100644 --- a/README.md +++ b/README.md @@ -38,5 +38,6 @@ These settings can be adjusted according to your preferences and needs. It's imp ## Changelog +- 11.0.4: use dall-e-3 model from OpenAI, use stable-diffusion-xl-1024-v1-0 from StabilityAI, fix for TCA buttons - 11.0.3: upscale and outpaint via context menu in filelist, generate image from filelist module, generate image from image content - 11.0.0: initial release for TYPO3 10.4