Commit bd362c6d authored by 朱国瑞's avatar 朱国瑞

修改丰富场景模式分镜逻辑

parent 975e848f
......@@ -42,7 +42,7 @@ export default class utils {
for (let i = 0; i < sentences.length; i++) {
const str = sentences[i];
currentSentence += str + ',';
if (i < sentences.length - 1 && (currentSentence + sentences[i + 1]).length <= 15) {
if (i < sentences.length - 1 && (currentSentence + sentences[i + 1]).length <= 20) {
continue;
}
result_sentences.push(currentSentence.endsWith(",") ? currentSentence.slice(0, -1) : currentSentence);
......@@ -52,26 +52,33 @@ export default class utils {
return result_sentences;
}
static splitMoreText (sentences: string[]) {
// console.log(sentences)
let result_sentences: string[] = [];
for (let i = 0; i < sentences.length; i++) {
const str = sentences[i];
let tempSentences = str.split(/[!|?|。|!|?|,|,]/);
let newList = utils.splitDetailText(tempSentences);
result_sentences = result_sentences.concat(newList);
}
// console.log('result_sentences=', result_sentences);
return result_sentences;
};
// 拆分文本
static splitText(str: string, type: string = 'default') {
str = str.replaceAll('“','').replaceAll('”','')
str = str.replaceAll('“', '').replaceAll('”', '')
// 使用正则表达式拆分文本
let sentences: string[] = [];
if(type == 'default'){
sentences = str.split(/[!|?|。|!|?]/);
} else {
sentences = str.split(/[!|?|。|!|?|,|,]/);
}
let sentences = str.split(/[!|?|。|!|?]/)
// 过滤掉长度为 0 的句子
sentences = sentences.filter(s => s.length > 0);
sentences = sentences.filter((s) => s.length > 0)
// 过滤掉只包含标点符号的句子
sentences = sentences.filter(s => !utils.containsOnlyPunctuation(s));
if(type == 'default'){
sentences = sentences.filter((s) => !utils.containsOnlyPunctuation(s))
if (type == 'default') {
return sentences
} else {
let detailSplit = utils.splitDetailText(sentences);
return detailSplit;
let detailSplit = utils.splitMoreText(sentences)
return detailSplit
}
}
......
<script setup lang="ts">
import { onMounted, reactive, ref, nextTick } from "vue";
import { Sunny, UploadFilled, Delete, Download, Plus, ZoomIn, Files } from "@element-plus/icons-vue";
import text2videoService from "@/api/service/text2videoService";
import utils from "@/utils/utils";
import {
ElMessage, genFileId,
type UploadInstance,
type UploadProps,
type UploadRawFile,
type UploadFile
type UploadRawFile
} from "element-plus";
import text2videoService from "@/api/service/text2videoService";
import utils from "@/utils/utils";
import { useManyValues } from './compositions/useManyValues'
import { nextTick, onMounted, reactive, ref } from "vue";
import { useManyValues } from './compositions/useManyValues';
const debug = ref(import.meta.env.MODE === 'production' ? false : true);
// const debug = ref(false);
......@@ -281,7 +279,10 @@ const onAdapt = async (type: string) => {
console.log('分镜,生成task_id=', form.task_id)
}
// 按标点拆分成分镜
const sentences = utils.splitText(form.chatgpt_answer, type);
let sentences = utils.splitText(form.chatgpt_answer);
if (type == "more_scene" && sentences.length < 5) {
sentences = utils.splitText(form.chatgpt_answer, type);
}
// console.log(sentences.length)
// 分镜
form.adapt_result_json = [];
......@@ -1896,40 +1897,40 @@ const onSubmitUploadAndModifyProductPicInPaint = async () => {
try {
let keywords_en = await text2videoService.submitTranslateToEn(utils.aesEncrypt(update_and_modify_product.inPaintPrompt), form.task_id, "true");
let sd_prompt = keywords_en.replace(/"/g, '') + "," + sd_prompt_prefix;
// const sd_img = await text2videoService.submitSDInPaint(
// form.task_id,
// img_id,
// sd_prompt,
// sd_negative_prompt_prefix,
// form.img_size.width,
// form.img_size.height,
// sampler_index,
// seed,
// steps,
// cfg_scale,
// "false",
// model,
// base_img,
// mask,
// "img_path",
// );
const sd_img = await text2videoService.submitSDInPaint(
form.task_id,
img_id,
utils.aesEncrypt(sd_prompt),
utils.aesEncrypt(sd_negative_prompt_prefix),
utils.aesEncrypt(form.img_size.width),
utils.aesEncrypt(form.img_size.height),
utils.aesEncrypt(sampler_index),
utils.aesEncrypt(seed),
utils.aesEncrypt(steps),
utils.aesEncrypt(cfg_scale),
"true",
utils.aesEncrypt(model),
utils.aesEncrypt(base_img),
utils.aesEncrypt(mask),
utils.aesEncrypt("img_path"),
sd_prompt,
sd_negative_prompt_prefix,
form.img_size.width,
form.img_size.height,
sampler_index,
seed,
steps,
cfg_scale,
"false",
model,
base_img,
mask,
"img_path",
);
// const sd_img = await text2videoService.submitSDInPaint(
// form.task_id,
// img_id,
// utils.aesEncrypt(sd_prompt),
// utils.aesEncrypt(sd_negative_prompt_prefix),
// utils.aesEncrypt(form.img_size.width),
// utils.aesEncrypt(form.img_size.height),
// utils.aesEncrypt(sampler_index),
// utils.aesEncrypt(seed),
// utils.aesEncrypt(steps),
// utils.aesEncrypt(cfg_scale),
// "true",
// utils.aesEncrypt(model),
// utils.aesEncrypt(base_img),
// utils.aesEncrypt(mask),
// utils.aesEncrypt("img_path"),
// );
update_and_modify_product.pic = sd_img.domain_image_path + "?v=" + utils.genDateTimeStr();
update_and_modify_product.pic_local = sd_img.local_image_path;
} catch (error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment