describe neutral
This commit is contained in:
parent
708c87c02c
commit
74aba1bdf9
1 changed files with 22 additions and 41 deletions
31
generate.py
31
generate.py
|
|
@ -420,7 +420,8 @@ def replace_character_motion_control(item, character, keep=False):
|
|||
img.add(ai)
|
||||
return ai
|
||||
|
||||
def describe_video_neutral(url):
|
||||
def describe_video(url, neutral=False):
|
||||
if neutral:
|
||||
prompt = (
|
||||
"Detect cuts or scene changes and describe each scene, use as much details as you can. "
|
||||
"Describe each person incudling detalied apreance, haircut in a gender neutral way, "
|
||||
|
|
@ -429,21 +430,7 @@ def describe_video_neutral(url):
|
|||
"Use the format: <description of scene 1>. CAMERA CUT TO <description of scene 2>. CAMERA CUT TO <description of scene 3>. "
|
||||
"Don't mention it if you don't find a cut."
|
||||
)
|
||||
data = {
|
||||
"input": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "input_video", "video_url": url, "fps": 1},
|
||||
{"type": "input_text", "text": prompt},
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
response = bytedance_response(data)
|
||||
return response["output"][1]["content"][0]["text"]
|
||||
|
||||
def describe_video(url):
|
||||
else:
|
||||
prompt = (
|
||||
"Detect cuts or scene changes and describe each scene, use as much details as you can. "
|
||||
"Describe each person incudling detalied apreance, ethnicity, haircolor, haircut, "
|
||||
|
|
@ -466,23 +453,17 @@ def describe_video(url):
|
|||
response = bytedance_response(data)
|
||||
return response["output"][1]["content"][0]["text"]
|
||||
|
||||
|
||||
def describe_item(item):
|
||||
def describe_item(item, neutral=False):
|
||||
if isinstance(item, str):
|
||||
item = Item.objects.get(public_id=item)
|
||||
video_url = public_video_url(item)
|
||||
return describe_video(video_url)
|
||||
|
||||
return describe_video(video_url, neutral)
|
||||
|
||||
def reshoot_item(item, extra_prompt=None, first_frame=None, keep=False):
|
||||
if isinstance(item, str):
|
||||
item = Item.objects.get(public_id=item)
|
||||
duration = item.sort.duration
|
||||
frames = int(duration * 24)
|
||||
if first_frame:
|
||||
prompt = describe_item_neutral(item)
|
||||
else:
|
||||
prompt = describe_item(item)
|
||||
prompt = describe_item(item, first_frame is not None)
|
||||
|
||||
if extra_prompt:
|
||||
prompt += " " + extra_prompt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue