@@ -148,7 +148,7 @@ const hotWords = ref<string[]>([
148
148
const message = useMessage ()
149
149
150
150
// 采样方法 TODO @fan:有 Euler a;DPM++ 2S a;DPM++ 2M;DPM++ SDE;DPM++ 2M SDE;UniPC;Restart;另外,要不这种枚举,我们都放到 image 里?写成 stableDiffusionSampler ?
151
- const selectSampler = ref <any >({} ) // 模型
151
+ const selectSampler = ref <string >( ' DDIM ' ) // 模型
152
152
// DDIM DDPM K_DPMPP_2M K_DPMPP_2S_ANCESTRAL K_DPM_2 K_DPM_2_ANCESTRAL K_EULER K_EULER_ANCESTRAL K_HEUN K_LMS
153
153
const sampler = ref <ImageModelVO []>([
154
154
{
@@ -192,12 +192,11 @@ const sampler = ref<ImageModelVO[]>([
192
192
name: ' K_LMS'
193
193
},
194
194
])
195
- selectSampler .value = sampler .value [0 ]
196
195
197
196
// 风格
198
197
// 3d-model analog-film anime cinematic comic-book digital-art enhance fantasy-art isometric
199
198
// line-art low-poly modeling-compound neon-punk origami photographic pixel-art tile-texture
200
- const selectStylePreset = ref <any >({} ) // 模型
199
+ const selectStylePreset = ref <string >( ' 3d-model ' ) // 模型
201
200
const stylePresets = ref <ImageModelVO []>([
202
201
{
203
202
key: ' 3d-model' ,
@@ -269,13 +268,11 @@ const stylePresets = ref<ImageModelVO[]>([
269
268
name: ' tile-texture'
270
269
},
271
270
])
272
- selectStylePreset .value = stylePresets .value [0 ]
273
-
274
271
275
272
// 文本提示相匹配的图像(clip_guidance_preset) 简称 CLIP
276
273
// https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage
277
274
// FAST_BLUE FAST_GREEN NONE SIMPLE SLOW SLOWER SLOWEST
278
- const selectClipGuidancePreset = ref <any >({} ) // 模型
275
+ const selectClipGuidancePreset = ref <string >( ' NONE ' ) // 模型
279
276
const clipGuidancePresets = ref <ImageModelVO []>([
280
277
{
281
278
key: ' NONE' ,
@@ -306,7 +303,6 @@ const clipGuidancePresets = ref<ImageModelVO[]>([
306
303
name: ' SLOWEST'
307
304
},
308
305
])
309
- selectClipGuidancePreset .value = clipGuidancePresets .value [0 ]
310
306
311
307
const steps = ref <number >(20 ) // 迭代步数
312
308
const seed = ref <number >(42 ) // 控制生成图像的随机性
@@ -334,7 +330,7 @@ const handleHotWordClick = async (hotWord: string) => {
334
330
const handleGenerateImage = async () => {
335
331
// 二次确认
336
332
await message .confirm (` 确认生成内容? ` )
337
- if (hasChinese (prompt .value )) {
333
+ if (await hasChinese (prompt .value )) {
338
334
message .alert (' 暂不支持中文!' )
339
335
return
340
336
}
@@ -354,9 +350,9 @@ const handleGenerateImage = async () => {
354
350
seed: seed .value , // 随机种子
355
351
steps: steps .value , // 图片生成步数
356
352
scale: scale .value , // 引导系数
357
- sampler: selectSampler .value . key , // 采样算法
353
+ sampler: selectSampler .value , // 采样算法
358
354
clipGuidancePreset: selectClipGuidancePreset .value .key , // 文本提示相匹配的图像 CLIP
359
- stylePreset: selectStylePreset .value . key , // 风格
355
+ stylePreset: selectStylePreset .value , // 风格
360
356
}
361
357
} as ImageDrawReqVO
362
358
await ImageApi .drawImage (form )
@@ -371,6 +367,14 @@ const handleGenerateImage = async () => {
371
367
/** 填充值 */
372
368
const settingValues = async (imageDetail : ImageVO ) => {
373
369
prompt .value = imageDetail .prompt
370
+ imageWidth .value = imageDetail .width
371
+ imageHeight .value = imageDetail .height
372
+ seed .value = imageDetail .options ?.seed
373
+ steps .value = imageDetail .options ?.steps
374
+ scale .value = imageDetail .options ?.scale
375
+ selectSampler .value = imageDetail .options ?.sampler
376
+ selectClipGuidancePreset .value = imageDetail .options ?.clipGuidancePreset
377
+ selectStylePreset .value = imageDetail .options ?.stylePreset
374
378
}
375
379
376
380
/** 暴露组件方法 */
0 commit comments