我将Orhanerday\OpenAi库导入到我的DALL-E示例项目中,但是当我提供图像时,我得到了Invalid input image - format must be in ['RGBA'], got RGB.错误。我在网上搜索这个错误,但一无所获。
我的代码看起来像
<?php
require __DIR__ . '/vendor/autoload.php'; // remove this line if you use a PHP Framework.
use Orhanerday\OpenAi\OpenAi;
$open_ai_key = getenv("OPENAIKEY");
$open_ai = new OpenAi($open_ai_key);
$otter = curl_file_create("C:\Users\dotor\OneDrive\Desktop\dalle-examples\otter.png");
$mask = curl_file_create("C:\Users\dotor\OneDrive\Desktop\dalle-examples\mask.png");
$result = $open_ai->imageEdit([
"image" => $otter,
"mask" => $mask,
"prompt" => "A cute baby sea otter wearing a beret",
"n" => 2,
"size" => "256x256",
]);
var_dump($result);Png档案;
otter.png;

mask.png;

我需要得到一个没有任何错误的结果,什么是RGBA文件,我如何提供?
发布于 2022-11-06 19:24:15
RGBA中的A代表Alpha,这只是一个不透明的值。因为这是OpenAI所需的类型,所以应该利用现有的库将普通的RGB转换为RGBA。在python中,我使用(PIL)转换函数来完成这项任务。
https://stackoverflow.com/questions/74325785
复制相似问题