【增加】stable-diffusion 增加重新生成

pull/470/MERGE
cherishsince 2024-07-04 11:18:36 +08:00
parent d974124918
commit 807e9272a5
2 changed files with 18 additions and 14 deletions

View File

@ -40,9 +40,9 @@ import {ImageVO} from "@/api/ai/image";
const imageTaskRef = ref<any>() // image task ref
const dall3Ref = ref<any>() // image task ref
const midjourneyRef = ref<any>() // image task ref
const stableDiffusionRef = ref<any>() // image task ref
const dall3Ref = ref<any>() // openai ref
const midjourneyRef = ref<any>() // midjourney ref
const stableDiffusionRef = ref<any>() // stable diffusion ref
//
const selectPlatform = ref('StableDiffusion')
@ -79,7 +79,7 @@ const handlerDrawComplete = async (type) => {
const handlerRegeneration = async (imageDetail: ImageVO) => {
//
selectPlatform.value = imageDetail.platform
console.log('切换平台', imageDetail.platform)
// imageDetail
if (imageDetail.platform === AiPlatformEnum.MIDJOURNEY) {
await nextTick(async () => {

View File

@ -148,7 +148,7 @@ const hotWords = ref<string[]>([
const message = useMessage()
// TODO @fan Euler aDPM++ 2S aDPM++ 2MDPM++ SDEDPM++ 2M SDEUniPCRestart image stableDiffusionSampler
const selectSampler = ref<any>({}) //
const selectSampler = ref<string>('DDIM') //
// 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
const sampler = ref<ImageModelVO[]>([
{
@ -192,12 +192,11 @@ const sampler = ref<ImageModelVO[]>([
name: 'K_LMS'
},
])
selectSampler.value = sampler.value[0]
//
// 3d-model analog-film anime cinematic comic-book digital-art enhance fantasy-art isometric
// line-art low-poly modeling-compound neon-punk origami photographic pixel-art tile-texture
const selectStylePreset = ref<any>({}) //
const selectStylePreset = ref<string>('3d-model') //
const stylePresets = ref<ImageModelVO[]>([
{
key: '3d-model',
@ -269,13 +268,11 @@ const stylePresets = ref<ImageModelVO[]>([
name: 'tile-texture'
},
])
selectStylePreset.value = stylePresets.value[0]
// (clip_guidance_preset) CLIP
// https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage
// FAST_BLUE FAST_GREEN NONE SIMPLE SLOW SLOWER SLOWEST
const selectClipGuidancePreset = ref<any>({}) //
const selectClipGuidancePreset = ref<string>('NONE') //
const clipGuidancePresets = ref<ImageModelVO[]>([
{
key: 'NONE',
@ -306,7 +303,6 @@ const clipGuidancePresets = ref<ImageModelVO[]>([
name: 'SLOWEST'
},
])
selectClipGuidancePreset.value = clipGuidancePresets.value[0]
const steps = ref<number>(20) //
const seed = ref<number>(42) //
@ -334,7 +330,7 @@ const handleHotWordClick = async (hotWord: string) => {
const handleGenerateImage = async () => {
//
await message.confirm(`确认生成内容?`)
if (hasChinese(prompt.value)) {
if (await hasChinese(prompt.value)) {
message.alert('暂不支持中文!')
return
}
@ -354,9 +350,9 @@ const handleGenerateImage = async () => {
seed: seed.value, //
steps: steps.value, //
scale: scale.value, //
sampler: selectSampler.value.key, //
sampler: selectSampler.value, //
clipGuidancePreset: selectClipGuidancePreset.value.key, // CLIP
stylePreset: selectStylePreset.value.key, //
stylePreset: selectStylePreset.value, //
}
} as ImageDrawReqVO
await ImageApi.drawImage(form)
@ -371,6 +367,14 @@ const handleGenerateImage = async () => {
/** 填充值 */
const settingValues = async (imageDetail: ImageVO) => {
prompt.value = imageDetail.prompt
imageWidth.value = imageDetail.width
imageHeight.value = imageDetail.height
seed.value = imageDetail.options?.seed
steps.value = imageDetail.options?.steps
scale.value = imageDetail.options?.scale
selectSampler.value = imageDetail.options?.sampler
selectClipGuidancePreset.value = imageDetail.options?.clipGuidancePreset
selectStylePreset.value = imageDetail.options?.stylePreset
}
/** 暴露组件方法 */