From 61bf6fb85b65ed2680a04b30bfd860e186fb350f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 9 Jul 2024 13:55:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91AI=EF=BC=9A=E7=BB=98=E5=9B=BE=20index.vue=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A2=B3=E7=90=86=2060%=EF=BC=88StableDiffusion.vue?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/image/index.ts | 6 +- .../ai/image/index/components/ImageDetail.vue | 82 +++- .../components/stableDiffusion/index.vue | 271 +++++++++++ src/views/ai/image/index/index.vue | 6 +- .../ai/image/index/stable-diffusion/index.vue | 437 ------------------ src/views/ai/utils/constants.ts | 170 +++++++ src/views/ai/utils/utils.ts | 2 +- 7 files changed, 523 insertions(+), 451 deletions(-) create mode 100644 src/views/ai/image/index/components/stableDiffusion/index.vue delete mode 100644 src/views/ai/image/index/stable-diffusion/index.vue diff --git a/src/api/ai/image/index.ts b/src/api/ai/image/index.ts index b4818818..43ddc7ec 100644 --- a/src/api/ai/image/index.ts +++ b/src/api/ai/image/index.ts @@ -12,11 +12,11 @@ export interface ImageVO { publicStatus: boolean // 公开状态 picUrl: string // 任务地址 errorMessage: string // 错误信息 - options: object // 配置 Map + options: any // 配置 Map taskId: number // 任务编号 buttons: ImageMidjourneyButtonsVO[] // mj 操作按钮 - createTime: string // 创建时间 - finishTime: string // 完成时间 + createTime: Date // 创建时间 + finishTime: Date // 完成时间 } export interface ImageDrawReqVO { diff --git a/src/views/ai/image/index/components/ImageDetail.vue b/src/views/ai/image/index/components/ImageDetail.vue index 1877f28e..32838b3d 100644 --- a/src/views/ai/image/index/components/ImageDetail.vue +++ b/src/views/ai/image/index/components/ImageDetail.vue @@ -20,8 +20,8 @@
时间
-
提交时间:{{ detail.createTime }}
-
生成时间:{{ detail.finishTime }}
+
提交时间:{{ formatTime(detail.createTime, 'yyyy-MM-dd HH:mm:ss') }}
+
生成时间:{{ formatTime(detail.finishTime, 'yyyy-MM-dd HH:mm:ss') }}
@@ -43,13 +43,73 @@ {{ detail.picUrl }} - -
+ +
+
采样方法
+
+ {{ + StableDiffusionSamplers.find( + (item: ImageModelVO) => item.key === detail?.options?.sampler + )?.name + }} +
+
+
+
CLIP
+
+ {{ + StableDiffusionClipGuidancePresets.find( + (item: ImageModelVO) => item.key === detail?.options?.clipGuidancePreset + )?.name + }} +
+
+
风格
- - - {{ detail?.options?.style }} + {{ + StableDiffusionStylePresets.find( + (item: ImageModelVO) => item.key === detail?.options?.stylePreset + )?.name + }} +
+
+
+
迭代步数
+
+ {{ detail?.options?.steps }} +
+
+
+
引导系数
+
+ {{ detail?.options?.scale }} +
+
+
+
随机因子
+
+ {{ detail?.options?.seed }}
@@ -58,6 +118,14 @@ + diff --git a/src/views/ai/image/index/index.vue b/src/views/ai/image/index/index.vue index ab164545..70666bf8 100644 --- a/src/views/ai/image/index/index.vue +++ b/src/views/ai/image/index/index.vue @@ -27,12 +27,12 @@ - diff --git a/src/views/ai/utils/constants.ts b/src/views/ai/utils/constants.ts index 337cfda3..8ceda73b 100644 --- a/src/views/ai/utils/constants.ts +++ b/src/views/ai/utils/constants.ts @@ -40,3 +40,173 @@ export const AiMusicStatusEnum = { SUCCESS: 20, // 已完成 FAIL: 30 // 已失败 } + +// ========== 【图片 UI】相关的枚举 ========== +export const ImageHotWords = [ + '中国旗袍', + '古装美女', + '卡通头像', + '机甲战士', + '童话小屋', + '中国长城' +] // 图片热词 + +export const ImageHotEnglishWords = [ + 'Chinese Cheongsam', + 'Ancient Beauty', + 'Cartoon Avatar', + 'Mech Warrior', + 'Fairy Tale Cottage', + 'The Great Wall of China' +] // 图片热词(英文) + +export interface ImageModelVO { + key: string + name: string +} + +export const StableDiffusionSamplers = ref([ + { + key: 'DDIM', + name: 'DDIM' + }, + { + key: 'DDPM', + name: 'DDPM' + }, + { + key: 'K_DPMPP_2M', + name: 'K_DPMPP_2M' + }, + { + key: 'K_DPMPP_2S_ANCESTRAL', + name: 'K_DPMPP_2S_ANCESTRAL' + }, + { + key: 'K_DPM_2', + name: 'K_DPM_2' + }, + { + key: 'K_DPM_2_ANCESTRAL', + name: 'K_DPM_2_ANCESTRAL' + }, + { + key: 'K_EULER', + name: 'K_EULER' + }, + { + key: 'K_EULER_ANCESTRAL', + name: 'K_EULER_ANCESTRAL' + }, + { + key: 'K_HEUN', + name: 'K_HEUN' + }, + { + key: 'K_LMS', + name: 'K_LMS' + } +]) + +export const StableDiffusionStylePresets = ref([ + { + key: '3d-model', + name: '3d-model' + }, + { + key: 'analog-film', + name: 'analog-film' + }, + { + key: 'anime', + name: 'anime' + }, + { + key: 'cinematic', + name: 'cinematic' + }, + { + key: 'comic-book', + name: 'comic-book' + }, + { + key: 'digital-art', + name: 'digital-art' + }, + { + key: 'enhance', + name: 'enhance' + }, + { + key: 'fantasy-art', + name: 'fantasy-art' + }, + { + key: 'isometric', + name: 'isometric' + }, + { + key: 'line-art', + name: 'line-art' + }, + { + key: 'low-poly', + name: 'low-poly' + }, + { + key: 'modeling-compound', + name: 'modeling-compound' + }, + // neon-punk origami photographic pixel-art tile-texture + { + key: 'neon-punk', + name: 'neon-punk' + }, + { + key: 'origami', + name: 'origami' + }, + { + key: 'photographic', + name: 'photographic' + }, + { + key: 'pixel-art', + name: 'pixel-art' + }, + { + key: 'tile-texture', + name: 'tile-texture' + } +]) + +export const StableDiffusionClipGuidancePresets = ref([ + { + key: 'NONE', + name: 'NONE' + }, + { + key: 'FAST_BLUE', + name: 'FAST_BLUE' + }, + { + key: 'FAST_GREEN', + name: 'FAST_GREEN' + }, + { + key: 'SIMPLE', + name: 'SIMPLE' + }, + { + key: 'SLOW', + name: 'SLOW' + }, + { + key: 'SLOWER', + name: 'SLOWER' + }, + { + key: 'SLOWEST', + name: 'SLOWEST' + } +]) diff --git a/src/views/ai/utils/utils.ts b/src/views/ai/utils/utils.ts index fc4f8e6c..ab45ae18 100644 --- a/src/views/ai/utils/utils.ts +++ b/src/views/ai/utils/utils.ts @@ -8,6 +8,6 @@ */ /** 判断字符串是否包含中文 */ -export const hasChinese = async (str) => { +export const hasChinese = (str: string) => { return /[\u4e00-\u9fa5]/.test(str) }