mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-02-08 14:44:58 +08:00
【增加】ai image 对接通义参数
This commit is contained in:
parent
51c6bfe42c
commit
c76b622722
@ -61,79 +61,13 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-space>
|
</el-space>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="group-item">
|
|
||||||
<div>
|
|
||||||
<el-text tag="b">风格</el-text>
|
|
||||||
</div>
|
|
||||||
<el-space wrap class="group-item-body">
|
|
||||||
<el-select v-model="stylePreset" placeholder="Select" size="large" class="!w-350px">
|
|
||||||
<el-option
|
|
||||||
v-for="item in stylePresetList"
|
|
||||||
:key="item.key"
|
|
||||||
:label="item.name"
|
|
||||||
:value="item.key"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-space>
|
|
||||||
</div>
|
|
||||||
<div class="group-item">
|
<div class="group-item">
|
||||||
<div>
|
<div>
|
||||||
<el-text tag="b">图片尺寸</el-text>
|
<el-text tag="b">图片尺寸</el-text>
|
||||||
</div>
|
</div>
|
||||||
<el-space wrap class="group-item-body">
|
<el-space wrap class="group-item-body">
|
||||||
<el-input v-model="width" class="w-170px" placeholder="图片宽度" />
|
<el-input v-model="width" type="number" class="w-170px" placeholder="图片宽度" />
|
||||||
<el-input v-model="height" class="w-170px" placeholder="图片高度" />
|
<el-input v-model="height" type="number" class="w-170px" placeholder="图片高度" />
|
||||||
</el-space>
|
|
||||||
</div>
|
|
||||||
<div class="group-item">
|
|
||||||
<div>
|
|
||||||
<el-text tag="b">迭代步数</el-text>
|
|
||||||
</div>
|
|
||||||
<el-space wrap class="group-item-body">
|
|
||||||
<el-input
|
|
||||||
v-model="steps"
|
|
||||||
type="number"
|
|
||||||
size="large"
|
|
||||||
class="!w-350px"
|
|
||||||
placeholder="Please input"
|
|
||||||
/>
|
|
||||||
</el-space>
|
|
||||||
</div>
|
|
||||||
<div class="group-item">
|
|
||||||
<div>
|
|
||||||
<el-text tag="b">引导系数</el-text>
|
|
||||||
</div>
|
|
||||||
<el-space wrap class="group-item-body">
|
|
||||||
<el-input
|
|
||||||
v-model="scale"
|
|
||||||
type="number"
|
|
||||||
size="large"
|
|
||||||
class="!w-350px"
|
|
||||||
placeholder="Please input"
|
|
||||||
/>
|
|
||||||
</el-space>
|
|
||||||
</div>
|
|
||||||
<div class="group-item">
|
|
||||||
<div>
|
|
||||||
<el-text tag="b">随机因子</el-text>
|
|
||||||
</div>
|
|
||||||
<el-space wrap class="group-item-body">
|
|
||||||
<el-input
|
|
||||||
v-model="seed"
|
|
||||||
type="number"
|
|
||||||
size="large"
|
|
||||||
class="!w-350px"
|
|
||||||
placeholder="Please input"
|
|
||||||
/>
|
|
||||||
</el-space>
|
|
||||||
</div>
|
|
||||||
<div class="group-item">
|
|
||||||
<div>
|
|
||||||
<el-text tag="b">参考图</el-text>
|
|
||||||
</div>
|
|
||||||
<el-space wrap class="group-item-body">
|
|
||||||
<UploadImg v-model="referImageUrl" height="120px" width="120px" />
|
|
||||||
</el-space>
|
</el-space>
|
||||||
</div>
|
</div>
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
@ -144,11 +78,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ImageApi, ImageDrawReqVO, ImageVO} from '@/api/ai/image'
|
import {ImageApi, ImageDrawReqVO, ImageVO} from '@/api/ai/image'
|
||||||
import {hasChinese} from '@/views/ai/utils/utils'
|
|
||||||
import {
|
import {
|
||||||
AiPlatformEnum,
|
AiPlatformEnum,
|
||||||
ImageHotWords, ImageModelVO, OtherPlatformEnum, TongYiWanXiangModels,
|
ImageHotWords,
|
||||||
TongYiWanXiangStylePresets
|
ImageModelVO,
|
||||||
|
OtherPlatformEnum,
|
||||||
|
TongYiWanXiangModels
|
||||||
} from '@/views/ai/utils/constants'
|
} from '@/views/ai/utils/constants'
|
||||||
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
@ -160,13 +95,7 @@ const selectHotWord = ref<string>('') // 选中的热词
|
|||||||
const prompt = ref<string>('') // 提示词
|
const prompt = ref<string>('') // 提示词
|
||||||
const width = ref<number>(512) // 图片宽度
|
const width = ref<number>(512) // 图片宽度
|
||||||
const height = ref<number>(512) // 图片高度
|
const height = ref<number>(512) // 图片高度
|
||||||
const steps = ref<number>(20) // 迭代步数
|
const otherPlatform = ref<string>(AiPlatformEnum.TONG_YI) // 平台
|
||||||
const seed = ref<number>(42) // 控制生成图像的随机性
|
|
||||||
const scale = ref<number>(7.5) // 引导系数
|
|
||||||
const referImageUrl = ref<any>() // 参考图
|
|
||||||
const stylePreset = ref<string>('-1') // 风格
|
|
||||||
const stylePresetList = ref<ImageModelVO[]>(TongYiWanXiangStylePresets) // 风格列表
|
|
||||||
const otherPlatform = ref<string>(AiPlatformEnum.TONG_YI_WAN_XIANG) // 平台
|
|
||||||
const models = ref<ImageModelVO[]>(TongYiWanXiangModels) // 模型
|
const models = ref<ImageModelVO[]>(TongYiWanXiangModels) // 模型
|
||||||
const model = ref<string>(models.value[0].key) // 模型
|
const model = ref<string>(models.value[0].key) // 模型
|
||||||
|
|
||||||
@ -198,16 +127,11 @@ const handleGenerateImage = async () => {
|
|||||||
// 发送请求
|
// 发送请求
|
||||||
const form = {
|
const form = {
|
||||||
platform: otherPlatform.value,
|
platform: otherPlatform.value,
|
||||||
model: '---', // 1
|
model: model.value, // 模型
|
||||||
prompt: prompt.value, // 提示词 1
|
prompt: prompt.value, // 提示词
|
||||||
width: width.value, // 图片宽度 1
|
width: width.value, // 图片宽度
|
||||||
height: height.value, // 图片高度 1
|
height: height.value, // 图片高度
|
||||||
options: {
|
options: {
|
||||||
seed: seed.value, // 随机种子 1
|
|
||||||
steps: steps.value, // 图片生成步数 1
|
|
||||||
scale: scale.value, // 引导系数 1
|
|
||||||
stylePreset: stylePreset.value, // 风格
|
|
||||||
referImage: referImageUrl.value // 参考图
|
|
||||||
}
|
}
|
||||||
} as ImageDrawReqVO
|
} as ImageDrawReqVO
|
||||||
await ImageApi.drawImage(form)
|
await ImageApi.drawImage(form)
|
||||||
@ -224,29 +148,22 @@ const settingValues = async (detail: ImageVO) => {
|
|||||||
prompt.value = detail.prompt
|
prompt.value = detail.prompt
|
||||||
width.value = detail.width
|
width.value = detail.width
|
||||||
height.value = detail.height
|
height.value = detail.height
|
||||||
seed.value = detail.options?.seed
|
|
||||||
steps.value = detail.options?.steps
|
|
||||||
scale.value = detail.options?.scale
|
|
||||||
stylePreset.value = detail.options?.stylePreset
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 平台切换 */
|
/** 平台切换 */
|
||||||
const handlerPlatformChange = async (platform) => {
|
const handlerPlatformChange = async (platform) => {
|
||||||
// 切换平台,切换模型、风格
|
// 切换平台,切换模型、风格
|
||||||
if (AiPlatformEnum.TONG_YI_WAN_XIANG === platform) {
|
if (AiPlatformEnum.YI_YAN === platform) {
|
||||||
models.value = TongYiWanXiangModels
|
models.value = TongYiWanXiangModels
|
||||||
stylePresetList.value = TongYiWanXiangStylePresets
|
|
||||||
} else {
|
} else {
|
||||||
models.value = []
|
models.value = []
|
||||||
stylePresetList.value = []
|
|
||||||
}
|
}
|
||||||
// 切换平台,默认选择一个风格
|
// 切换平台,默认选择一个风格
|
||||||
if (stylePresetList.value.length > 0) {
|
if (models.value.length > 0) {
|
||||||
model.value = models.value[0].key
|
model.value = models.value[0].key
|
||||||
stylePreset.value = stylePresetList.value[0].key
|
|
||||||
} else {
|
} else {
|
||||||
model.value = ''
|
model.value = ''
|
||||||
stylePreset.value = ''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,17 +21,15 @@ export const AiPlatformEnum = {
|
|||||||
STABLE_DIFFUSION: 'StableDiffusion', // Stability AI
|
STABLE_DIFFUSION: 'StableDiffusion', // Stability AI
|
||||||
MIDJOURNEY: 'Midjourney', // Midjourney
|
MIDJOURNEY: 'Midjourney', // Midjourney
|
||||||
SUNO: 'Suno', // Suno AI
|
SUNO: 'Suno', // Suno AI
|
||||||
TONG_YI_WAN_XIANG: 'TongYiWanXiang', //// 通义万相
|
|
||||||
YI_YAN_IMAGE: 'YiYanImage' //// 百度 image
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OtherPlatformEnum:ImageModelVO [] = [
|
export const OtherPlatformEnum:ImageModelVO [] = [
|
||||||
{
|
{
|
||||||
key: AiPlatformEnum.TONG_YI_WAN_XIANG,
|
key: AiPlatformEnum.TONG_YI,
|
||||||
name: '通义万相'
|
name: '通义万相'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: AiPlatformEnum.YI_YAN_IMAGE,
|
key: AiPlatformEnum.YI_YAN,
|
||||||
name: '百度图片'
|
name: '百度图片'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -203,6 +201,7 @@ export const StableDiffusionStylePresets: ImageModelVO[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// todo @芋艿 这些是通义的风格,看要不要删除
|
||||||
export const TongYiWanXiangStylePresets: ImageModelVO[] = [
|
export const TongYiWanXiangStylePresets: ImageModelVO[] = [
|
||||||
{
|
{
|
||||||
key: '-1',
|
key: '-1',
|
||||||
|
Loading…
Reference in New Issue
Block a user