Skip to content

Commit 807e927

Browse files
committed
【增加】stable-diffusion 增加重新生成
1 parent d974124 commit 807e927

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/views/ai/image/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ import {ImageVO} from "@/api/ai/image";
4040
4141
4242
const imageTaskRef = ref<any>() // image task ref
43-
const dall3Ref = ref<any>() // image task ref
44-
const midjourneyRef = ref<any>() // image task ref
45-
const stableDiffusionRef = ref<any>() // image task ref
43+
const dall3Ref = ref<any>() // openai ref
44+
const midjourneyRef = ref<any>() // midjourney ref
45+
const stableDiffusionRef = ref<any>() // stable diffusion ref
4646
4747
// 定义属性
4848
const selectPlatform = ref('StableDiffusion')
@@ -79,7 +79,7 @@ const handlerDrawComplete = async (type) => {
7979
const handlerRegeneration = async (imageDetail: ImageVO) => {
8080
// 切换平台
8181
selectPlatform.value = imageDetail.platform
82-
82+
console.log('切换平台', imageDetail.platform)
8383
// 根据不同平台填充 imageDetail
8484
if (imageDetail.platform === AiPlatformEnum.MIDJOURNEY) {
8585
await nextTick(async () => {

src/views/ai/image/stable-diffusion/index.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const hotWords = ref<string[]>([
148148
const message = useMessage()
149149
150150
// 采样方法 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') // 模型
152152
// 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
153153
const sampler = ref<ImageModelVO[]>([
154154
{
@@ -192,12 +192,11 @@ const sampler = ref<ImageModelVO[]>([
192192
name: 'K_LMS'
193193
},
194194
])
195-
selectSampler.value = sampler.value[0]
196195
197196
// 风格
198197
// 3d-model analog-film anime cinematic comic-book digital-art enhance fantasy-art isometric
199198
// 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') // 模型
201200
const stylePresets = ref<ImageModelVO[]>([
202201
{
203202
key: '3d-model',
@@ -269,13 +268,11 @@ const stylePresets = ref<ImageModelVO[]>([
269268
name: 'tile-texture'
270269
},
271270
])
272-
selectStylePreset.value = stylePresets.value[0]
273-
274271
275272
// 文本提示相匹配的图像(clip_guidance_preset) 简称 CLIP
276273
// https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage
277274
// FAST_BLUE FAST_GREEN NONE SIMPLE SLOW SLOWER SLOWEST
278-
const selectClipGuidancePreset = ref<any>({}) // 模型
275+
const selectClipGuidancePreset = ref<string>('NONE') // 模型
279276
const clipGuidancePresets = ref<ImageModelVO[]>([
280277
{
281278
key: 'NONE',
@@ -306,7 +303,6 @@ const clipGuidancePresets = ref<ImageModelVO[]>([
306303
name: 'SLOWEST'
307304
},
308305
])
309-
selectClipGuidancePreset.value = clipGuidancePresets.value[0]
310306
311307
const steps = ref<number>(20) // 迭代步数
312308
const seed = ref<number>(42) // 控制生成图像的随机性
@@ -334,7 +330,7 @@ const handleHotWordClick = async (hotWord: string) => {
334330
const handleGenerateImage = async () => {
335331
// 二次确认
336332
await message.confirm(`确认生成内容?`)
337-
if (hasChinese(prompt.value)) {
333+
if (await hasChinese(prompt.value)) {
338334
message.alert('暂不支持中文!')
339335
return
340336
}
@@ -354,9 +350,9 @@ const handleGenerateImage = async () => {
354350
seed: seed.value, // 随机种子
355351
steps: steps.value, // 图片生成步数
356352
scale: scale.value, // 引导系数
357-
sampler: selectSampler.value.key, // 采样算法
353+
sampler: selectSampler.value, // 采样算法
358354
clipGuidancePreset: selectClipGuidancePreset.value.key, // 文本提示相匹配的图像 CLIP
359-
stylePreset: selectStylePreset.value.key, // 风格
355+
stylePreset: selectStylePreset.value, // 风格
360356
}
361357
} as ImageDrawReqVO
362358
await ImageApi.drawImage(form)
@@ -371,6 +367,14 @@ const handleGenerateImage = async () => {
371367
/** 填充值 */
372368
const settingValues = async (imageDetail: ImageVO) => {
373369
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
374378
}
375379
376380
/** 暴露组件方法 */

0 commit comments

Comments
 (0)