add luma custom extend (#119)
This commit is contained in:
1 parent
2e652a658b
commit
65163e31d7
10 files changed
+287
-12
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"comment": "fit luma extend custom",
|
||||
"packageName": "@acedatacloud/nexior",
|
||||
"email": "1348977728@qq.com",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -1,20 +1,28 @@
|
||||
<template>
|
||||
<div class="panel">
|
||||
<div class="config">
|
||||
<extend-from-input v-if="config?.action === 'extend'" class="mb-4" />
|
||||
<extend-from-input v-if="config?.video_id || config?.video_url" class="mb-4" />
|
||||
<prompt-input class="mb-4" />
|
||||
<start-image-url-input v-if="!config?.action === 'extend'" class="mb-4" />
|
||||
<custom-selector v-if="!config?.video_id" class="mb-4" />
|
||||
<upload-video v-if="config?.custom" class="mb-4" />
|
||||
<start-image-url-input v-if="!(config?.video_id || config?.video_url) && !config?.custom" class="mb-4" />
|
||||
<end-image-url-input class="mb-4" />
|
||||
<enhancement-selector class="mb-4" />
|
||||
<loop-selector class="mb-4" />
|
||||
<div class="actions">
|
||||
<el-button v-if="config?.action !== 'extend'" type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<el-button
|
||||
v-if="config?.video_url !== undefined || config?.custom"
|
||||
type="primary"
|
||||
class="btn w-full"
|
||||
round
|
||||
@click="onGenerate"
|
||||
>
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('luma.button.generate') }}
|
||||
{{ $t('luma.button.extend') }}
|
||||
</el-button>
|
||||
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('luma.button.extend') }}
|
||||
{{ $t('luma.button.generate') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,9 +34,12 @@ import { defineComponent } from 'vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import EnhancementSelector from './config/EnhancementSelector.vue';
|
||||
import CustomSelector from './config/CustomSelector.vue';
|
||||
import LoopSelector from './config/LoopSelector.vue';
|
||||
import EndImageUrlInput from './config/EndImageUrlInput.vue';
|
||||
import StartImageUrlInput from './config/StartImageUrlInput.vue';
|
||||
// @ts-ignore
|
||||
import UploadVideo from './config/UploadVideo.vue';
|
||||
import PromptInput from './config/PromptInput.vue';
|
||||
import ExtendFromInput from './config/ExtendFromInput.vue';
|
||||
export default defineComponent({
|
||||
@@ -41,7 +52,9 @@ export default defineComponent({
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
PromptInput,
|
||||
ExtendFromInput
|
||||
ExtendFromInput,
|
||||
CustomSelector,
|
||||
UploadVideo
|
||||
},
|
||||
emits: ['generate'],
|
||||
computed: {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.custom') }}</h2>
|
||||
<el-switch v-model="value" class="value" />
|
||||
<info-icon :content="$t('luma.description.custom')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSwitch } from 'element-plus';
|
||||
import { LUMA_DEFAULT_CUSTOM } from '@/constants';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export default defineComponent({
|
||||
name: 'CustomSelector',
|
||||
components: {
|
||||
ElSwitch,
|
||||
InfoIcon
|
||||
},
|
||||
computed: {
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.custom;
|
||||
},
|
||||
set(val) {
|
||||
console.debug('set custom', val);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
custom: val
|
||||
});
|
||||
console.log(JSON.stringify(this.$store.state.luma?.config));
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.value === undefined) {
|
||||
this.value = LUMA_DEFAULT_CUSTOM;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
flex: 1;
|
||||
margin-left: 60px; // Adjust this value as needed
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -22,6 +22,7 @@ import VuePlyr from '@skjnldsv/vue-plyr';
|
||||
// @ts-ignore
|
||||
import { ILumaTask } from '@/models';
|
||||
import '@skjnldsv/vue-plyr/dist/vue-plyr.css';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ExtendFromInput',
|
||||
components: { VuePlyr },
|
||||
@@ -50,15 +51,15 @@ export default defineComponent({
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between; // 添加这行
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.input-wrapper {
|
||||
width: 150px; // 根据需要调整宽度
|
||||
margin-left: 30px; // 增加左边距
|
||||
width: 150px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<h2 class="title">{{ $t('luma.name.videoUrl') }}</h2>
|
||||
<div class="upload-wrapper">
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
accept=".mp4"
|
||||
name="file"
|
||||
class="value"
|
||||
:show-file-list="true"
|
||||
:limit="1"
|
||||
:multiple="false"
|
||||
:action="uploadUrl"
|
||||
:before-upload="beforeUpload"
|
||||
:on-exceed="onExceed"
|
||||
:on-error="onError"
|
||||
:on-success="onSuccess"
|
||||
:headers="headers"
|
||||
>
|
||||
<el-button size="small" type="primary" round>{{ $t('luma.button.uploadVideoUrl') }}</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
<info-icon :content="$t('luma.description.videoUrl')" class="info" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton, ElUpload, ElMessage, UploadFiles } from 'element-plus';
|
||||
import { getBaseUrlPlatform } from '@/utils';
|
||||
import InfoIcon from '@/components/common/InfoIcon.vue';
|
||||
export const DEFAULT_CONTENT = '';
|
||||
|
||||
interface IData {
|
||||
fileList: UploadFiles;
|
||||
uploadUrl: string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UploadVideo',
|
||||
components: {
|
||||
ElUpload,
|
||||
ElButton,
|
||||
InfoIcon
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
fileList: [],
|
||||
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
return {
|
||||
Authorization: `Bearer ${this.$store.state.token.access}`
|
||||
};
|
||||
},
|
||||
urls(): string[] {
|
||||
// @ts-ignore
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.luma?.config?.video_url;
|
||||
},
|
||||
set(val: string) {
|
||||
const url = this.urls?.[0];
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
video_url: url
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
this.onSetVideoUrl();
|
||||
},
|
||||
methods: {
|
||||
onExceed() {
|
||||
ElMessage.warning(this.$t('luma.message.uploadVideoExceed'));
|
||||
},
|
||||
onError() {
|
||||
ElMessage.error(this.$t('luma.message.uploadVideoError'));
|
||||
},
|
||||
beforeUpload(file: File) {
|
||||
const isMP4 = file.type === 'video/mp4';
|
||||
const isLt10M = file.size / 1024 / 1024 < 10;
|
||||
|
||||
if (!isMP4) {
|
||||
ElMessage.error(this.$t('luma.message.uploadVideoTypeFailed'));
|
||||
return false;
|
||||
}
|
||||
if (!isLt10M) {
|
||||
ElMessage.error(this.$t('luma.message.uploadVideoSizeExceed'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onSetVideoUrl() {
|
||||
const url = this.urls?.[0];
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
video_url: url,
|
||||
action: 'extend'
|
||||
});
|
||||
},
|
||||
async onSuccess() {
|
||||
this.onSetVideoUrl();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between; // Distribute space evenly
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
width: 30%;
|
||||
}
|
||||
.value {
|
||||
flex: 1;
|
||||
margin-left: 60px; // Adjust this value as needed
|
||||
}
|
||||
.upload-wrapper {
|
||||
transform: translate(-26px, 5px); // Move left and down
|
||||
}
|
||||
.info {
|
||||
margin-left: auto; // Pushes the info icon to the right
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -14,6 +14,11 @@
|
||||
<p v-if="modelValue?.request?.prompt" class="prompt mt-2">
|
||||
{{ modelValue?.request?.prompt }}
|
||||
<span v-if="!modelValue?.response"> - ({{ $t('luma.status.pending') }}) </span>
|
||||
<span
|
||||
v-if="modelValue?.response?.data?.state === 'processing' || modelValue?.response?.data?.state === 'pending'"
|
||||
>
|
||||
- ({{ $t('luma.status.processing') }})
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Display success message -->
|
||||
@@ -21,7 +26,7 @@
|
||||
<div class="image-wrapper">
|
||||
<VideoPlayer :model-value="modelValue" />
|
||||
</div>
|
||||
<div v-if="modelValue?.response" :class="{ operations: true, 'mt-2': true }">
|
||||
<div v-if="modelValue?.response && !config?.custom" :class="{ operations: true, 'mt-2': true }">
|
||||
<el-tooltip class="box-item" effect="dark" :content="$t('luma.message.extendVideo')" placement="top-start">
|
||||
<el-button type="info" size="small" class="btn-action" @click="onExtend($event, modelValue?.response)">
|
||||
{{ $t('luma.button.extend') }}
|
||||
@@ -113,13 +118,15 @@ export default defineComponent({
|
||||
computed: {
|
||||
application() {
|
||||
return this.$store.state.luma?.application;
|
||||
},
|
||||
config() {
|
||||
return this.$store.state.luma?.config;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onExtend(event: MouseEvent, response: ILumaGenerateResponse) {
|
||||
event.stopPropagation();
|
||||
console.log('on extend');
|
||||
// download url here
|
||||
// extend url here
|
||||
console.debug('set config', response);
|
||||
this.$store.commit('luma/setConfig', {
|
||||
...this.$store.state.luma?.config,
|
||||
|
||||
@@ -2,3 +2,4 @@ export const LUMA_SERVICE_ID = 'dff45a0d-2858-4936-8e2b-3d49c52aff11';
|
||||
|
||||
export const LUMA_DEFAULT_ENHANCEMENT = false;
|
||||
export const LUMA_DEFAULT_LOOP = false;
|
||||
export const LUMA_DEFAULT_CUSTOM = false;
|
||||
@@ -39,6 +39,10 @@
|
||||
"message": "首帧图片",
|
||||
"description": "要生成的 QR 码的种子"
|
||||
},
|
||||
"name.videoUrl": {
|
||||
"message": "自定义视频",
|
||||
"description": "要生成的 QR 码的种子"
|
||||
},
|
||||
"name.endImageUrl": {
|
||||
"message": "尾帧图片",
|
||||
"description": "要生成的 QR 码的种子"
|
||||
@@ -75,6 +79,10 @@
|
||||
"message": "提示词增强",
|
||||
"description": "要生成的 QR 码的高级设置"
|
||||
},
|
||||
"name.custom": {
|
||||
"message": "自定义扩展",
|
||||
"description": "自定义扩展视频"
|
||||
},
|
||||
"name.extend": {
|
||||
"message": "扩展视频来自",
|
||||
"description": "内容输入的提示"
|
||||
@@ -131,10 +139,18 @@
|
||||
"message": "如果您不确定如何书写提示文字,请启用输入提示文字的增强功能。",
|
||||
"description": "参数'qrw'的描述"
|
||||
},
|
||||
"description.custom": {
|
||||
"message": "如果您想上传自己的视频来扩展视频,请打开此按钮。",
|
||||
"description": "参数'qrw'的描述"
|
||||
},
|
||||
"description.startImageUrl": {
|
||||
"message": "首帧图像的 URL,它将是生成视频的第一帧。",
|
||||
"description": "参数'steps'的描述"
|
||||
},
|
||||
"description.videoUrl": {
|
||||
"message": "上传自定义扩展的视频URL,它将是扩展视频的视频。",
|
||||
"description": "参数'steps'的描述"
|
||||
},
|
||||
"description.endImageUrl": {
|
||||
"message": "尾帧图像的 URL,它将是生成视频的最后一帧。",
|
||||
"description": "参数'steps'的描述"
|
||||
@@ -147,6 +163,10 @@
|
||||
"message": "等待中",
|
||||
"description": "任务的等待状态"
|
||||
},
|
||||
"status.processing": {
|
||||
"message": "处理中",
|
||||
"description": "任务的等待状态"
|
||||
},
|
||||
"placeholder.paddingNoise": {
|
||||
"message": "请选择...",
|
||||
"description": "填充噪音输入的占位符"
|
||||
@@ -207,6 +227,10 @@
|
||||
"message": "上传图片",
|
||||
"description": "上传二维码的按钮文本"
|
||||
},
|
||||
"button.uploadVideoUrl": {
|
||||
"message": "上传视频",
|
||||
"description": "上传二维码的按钮文本"
|
||||
},
|
||||
"button.uploadEndImageUrl": {
|
||||
"message": "上传图片",
|
||||
"description": "上传二维码的按钮文本"
|
||||
@@ -355,6 +379,18 @@
|
||||
"message": "生成图像失败",
|
||||
"description": "图像生成失败时的消息"
|
||||
},
|
||||
"message.uploadVideoExceed": {
|
||||
"message": "上传首帧图片数量超过限制",
|
||||
"description": "上传首帧图片数量超过限制时的错误信息"
|
||||
},
|
||||
"message.uploadVideoSizeExceed": {
|
||||
"message": "上传文件大小不能超过 10MB!",
|
||||
"description": "上传文件大小不能超过 10MB!时的错误信息"
|
||||
},
|
||||
"message.uploadVideoTypeFailed": {
|
||||
"message": "上传文件必须是 MP4 格式!",
|
||||
"description": "上传文件必须是 MP4 格式!的错误信息"
|
||||
},
|
||||
"message.uploadStartImageExceed": {
|
||||
"message": "上传首帧图片数量超过限制",
|
||||
"description": "上传首帧图片数量超过限制时的错误信息"
|
||||
@@ -367,6 +403,10 @@
|
||||
"message": "上传首帧图片失败",
|
||||
"description": "上传首帧图片失败时的错误信息"
|
||||
},
|
||||
"message.uploadVideoError": {
|
||||
"message": "上传视频失败",
|
||||
"description": "上传首帧图片失败时的错误信息"
|
||||
},
|
||||
"message.uploadEndImageError": {
|
||||
"message": "上传尾帧图片失败",
|
||||
"description": "上传尾帧图片失败时的错误信息"
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface ILumaConfig {
|
||||
enhancement?: boolean;
|
||||
loop?: boolean;
|
||||
thumbnail_url?: string;
|
||||
custom?: boolean;
|
||||
}
|
||||
|
||||
export interface ILumaGenerateRequest {
|
||||
@@ -35,6 +36,10 @@ export interface ILumaGenerateResponse {
|
||||
thumbnail_width: number;
|
||||
thumbnail_height: number;
|
||||
trace_id: string;
|
||||
data?: {
|
||||
video_id?: string;
|
||||
state?: string;
|
||||
};
|
||||
error: {
|
||||
code?: string;
|
||||
message?: string;
|
||||
|
||||
@@ -152,6 +152,9 @@ export default defineComponent({
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success(this.$t('luma.message.startTaskSuccess'));
|
||||
this.$store.commit('luma/setConfig', {
|
||||
config: undefined
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
const response = error?.response?.data;
|
||||
|
||||
Reference in new issue
Block a user