Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
text2video-frontend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周成波
text2video-frontend
Commits
bd362c6d
Commit
bd362c6d
authored
May 14, 2024
by
朱国瑞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改丰富场景模式分镜逻辑
parent
975e848f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
51 deletions
+59
-51
utils.ts
src/utils/utils.ts
+20
-13
index.vue
src/views/home/index.vue
+39
-38
No files found.
src/utils/utils.ts
View file @
bd362c6d
...
...
@@ -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
.
split
DetailText
(
sentences
);
return
detailSplit
;
let
detailSplit
=
utils
.
split
MoreText
(
sentences
)
return
detailSplit
}
}
...
...
src/views/home/index.vue
View file @
bd362c6d
<
script
setup
lang=
"ts"
>
import
{
onMounted
,
reactive
,
ref
,
nextTick
}
from
"vu
e"
;
import
{
Sunny
,
UploadFilled
,
Delete
,
Download
,
Plus
,
ZoomIn
,
Files
}
from
"@element-plus/icons-vue
"
;
import
text2videoService
from
"@/api/service/text2videoServic
e"
;
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
)
,
"
tru
e"
,
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
,
"
fals
e"
,
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment