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

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

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