【代码评审】AI:图片 SD 的接入

pull/468/MERGE
YunaiV 2024-06-28 23:03:55 +08:00
parent d800143a88
commit 68c573d902
1 changed files with 65 additions and 65 deletions

View File

@ -8,7 +8,7 @@
v-model="prompt"
maxlength="1024"
rows="5"
style="width: 100%; margin-top: 15px;"
style="width: 100%; margin-top: 15px"
input-style="border-radius: 7px;"
placeholder="例如:童话里的小屋应该是什么样子?"
show-word-limit
@ -20,9 +20,10 @@
<el-text tag="b">随机热词</el-text>
</div>
<el-space wrap class="word-list">
<el-button round
<el-button
round
class="btn"
:type="(selectHotWord === hotWord ? 'primary' : 'default')"
:type="selectHotWord === hotWord ? 'primary' : 'default'"
v-for="hotWord in hotWords"
:key="hotWord"
@click="handlerHotWordClick(hotWord)"
@ -33,36 +34,20 @@
</div>
<div class="group-item">
<div>
<el-text tag="b">采样</el-text>
<el-text tag="b">采样方法</el-text>
</div>
<el-space wrap class="group-item-body">
<el-select
v-model="selectSampler"
placeholder="Select"
size="large"
style="width: 350px;"
>
<el-option
v-for="item in sampler"
:key="item.key"
:label="item.name"
:value="item.key"
/>
<el-select v-model="selectSampler" placeholder="Select" size="large" style="width: 350px">
<el-option v-for="item in sampler" :key="item.key" :label="item.name" :value="item.key" />
</el-select>
</el-space>
</div>
<div class="group-item">
<div>
<el-text tag="b">图片尺寸</el-text>
</div>
<el-space wrap class="group-item-body">
<el-select
v-model="selectImageSize"
placeholder="Select"
size="large"
style="width: 350px;"
>
<el-select v-model="selectImageSize" placeholder="Select" size="large" style="width: 350px">
<el-option
v-for="item in imageSizeList"
:key="item.key"
@ -77,29 +62,37 @@
<el-text tag="b">迭代步数</el-text>
</div>
<el-space wrap class="group-item-body">
<el-input v-model="steps" type="number" size="large" style="width: 350px" placeholder="Please input" />
<el-input
v-model="steps"
type="number"
size="large"
style="width: 350px"
placeholder="Please input"
/>
</el-space>
</div>
<div class="group-item">
<div>
<el-text tag="b">随机性</el-text>
<el-text tag="b">随机因子</el-text>
</div>
<el-space wrap class="group-item-body">
<el-input v-model="seed" type="number" size="large" style="width: 350px" placeholder="Please input" />
<el-input
v-model="seed"
type="number"
size="large"
style="width: 350px"
placeholder="Please input"
/>
</el-space>
</div>
<div class="btns">
<el-button type="primary"
size="large"
round
:loading="drawIn"
@click="handlerGenerateImage">
<el-button type="primary" size="large" round :loading="drawIn" @click="handlerGenerateImage">
{{ drawIn ? '生成中' : '生成内容' }}
</el-button>
</div>
</template>
<script setup lang="ts">
import {ImageApi, ImageDrawReqVO} from '@/api/ai/image';
import { ImageApi, ImageDrawReqVO } from '@/api/ai/image'
// image
interface ImageModelVO {
@ -110,91 +103,101 @@ interface ImageModelVO {
// image
interface ImageSizeVO {
key: string
width: string,
height: string,
width: string
height: string
}
//
const prompt = ref<string>('') //
const drawIn = ref<boolean>(false) //
const selectHotWord = ref<string>('') //
const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) //
const hotWords = ref<string[]>([
'中国旗袍',
'古装美女',
'卡通头像',
'机甲战士',
'童话小屋',
'中国长城'
]) //
const selectSampler = ref<any>({}) //
// message
const message = useMessage()
//
// TODO @fan Euler aDPM++ 2S aDPM++ 2MDPM++ SDEDPM++ 2M SDEUniPCRestart image stableDiffusionSampler
const sampler = ref<ImageModelVO[]>([
{
key: 'Euler a',
name: 'Euler a',
name: 'Euler a'
},
{
key: 'DPM++ 2S a Karras',
name: 'DPM++ 2S a Karras',
name: 'DPM++ 2S a Karras'
},
{
key: 'DPM++ 2M Karras',
name: 'DPM++ 2M Karras',
name: 'DPM++ 2M Karras'
},
{
key: 'DPM++ SDE Karras',
name: 'DPM++ SDE Karras',
name: 'DPM++ SDE Karras'
},
{
key: 'DPM++ 2M SDE Karras',
name: 'DPM++ 2M SDE Karras',
},
]) //
name: 'DPM++ 2M SDE Karras'
}
])
selectSampler.value = sampler.value[0]
// TODO @fan
// TODO @fan
const selectImageSize = ref<ImageSizeVO>({} as ImageSizeVO) // size
// TODO @fan widthheight key option
const imageSizeList = ref<ImageSizeVO[]>([
{
key: '512x512',
width: '512',
height: '512',
height: '512'
},
{
key: '1024x1024',
width: '1024',
height: '1024',
height: '1024'
},
{
key: '1024x1792',
width: '1024',
height: '1792',
height: '1792'
},
{
key: '1792x1024',
width: '1792',
height: '1024',
height: '1024'
},
{
key: '2048x2048',
width: '2048',
height: '2048',
height: '2048'
},
{
key: '720x1280',
width: '720',
height: '1280',
height: '1280'
},
{
key: '1080x1920',
width: '1080',
height: '1920',
height: '1920'
},
{
key: '1440x2560',
width: '1440',
height: '2560',
height: '2560'
},
{
key: '2160x3840',
width: '2160',
height: '3840',
},
height: '3840'
}
]) // size
selectImageSize.value = imageSizeList.value[0]
@ -239,8 +242,8 @@ const handlerGenerateImage = async () => {
options: {
sampler: selectSampler.value.key, //
seed: seed.value, //
steps: steps.value, //
},
steps: steps.value //
}
} as ImageDrawReqVO
//
await ImageApi.drawImage(form)
@ -251,10 +254,8 @@ const handlerGenerateImage = async () => {
drawIn.value = false
}
}
</script>
<style scoped lang="scss">
//
.prompt {
}
@ -288,7 +289,6 @@ const handlerGenerateImage = async () => {
}
}
.btns {
display: flex;
justify-content: center;