【修改todo】增加 sd 各种参数

This commit is contained in:
cherishsince
2024-06-30 16:10:56 +08:00
parent 246c233253
commit f300b8a1ae
3 changed files with 114 additions and 106 deletions

View File

@ -123,9 +123,16 @@ public class AiImageServiceImpl implements AiImageService {
.withResponseFormat("b64_json")
.build();
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.STABLE_DIFFUSION.getPlatform())) {
// https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage
// https://platform.stability.ai/docs/api-reference#tag/Text-to-Image/operation/textToImage
return StabilityAiImageOptions.builder().withModel(draw.getModel())
.withHeight(draw.getHeight()).withWidth(draw.getWidth()) // TODO @范:各种参数的接入
.withHeight(draw.getHeight()).withWidth(draw.getWidth())
.withSeed(Long.valueOf(draw.getOptions().get("seed")))
.withCfgScale(Float.valueOf(draw.getOptions().get("scale")))
.withSteps(Integer.valueOf(draw.getOptions().get("steps")))
.withSampler(String.valueOf(draw.getOptions().get("sampler")))
.withStylePreset(String.valueOf(draw.getOptions().get("stylePreset")))
.withClipGuidancePreset(String.valueOf(draw.getOptions().get("clipGuidancePreset")))
.build();
}
throw new IllegalArgumentException("不支持的 AI 平台:" + draw.getPlatform());