describe neutral
This commit is contained in:
parent
708c87c02c
commit
74aba1bdf9
1 changed files with 22 additions and 41 deletions
63
generate.py
63
generate.py
|
|
@ -420,15 +420,25 @@ def replace_character_motion_control(item, character, keep=False):
|
||||||
img.add(ai)
|
img.add(ai)
|
||||||
return ai
|
return ai
|
||||||
|
|
||||||
def describe_video_neutral(url):
|
def describe_video(url, neutral=False):
|
||||||
prompt = (
|
if neutral:
|
||||||
"Detect cuts or scene changes and describe each scene, use as much details as you can. "
|
prompt = (
|
||||||
"Describe each person incudling detalied apreance, haircut in a gender neutral way, "
|
"Detect cuts or scene changes and describe each scene, use as much details as you can. "
|
||||||
"describe each objects, animal or plant, describe foreground and backgroud, "
|
"Describe each person incudling detalied apreance, haircut in a gender neutral way, "
|
||||||
"describe from what angle the scene is filmed, incude details about camera model, lense, depth of field used to film this scene. "
|
"describe each objects, animal or plant, describe foreground and backgroud, "
|
||||||
"Use the format: <description of scene 1>. CAMERA CUT TO <description of scene 2>. CAMERA CUT TO <description of scene 3>. "
|
"describe from what angle the scene is filmed, incude details about camera model, lense, depth of field used to film this scene. "
|
||||||
"Don't mention it if you don't find a cut."
|
"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."
|
||||||
|
)
|
||||||
|
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, "
|
||||||
|
"describe each objects, animal or plant, describe foreground and backgroud, "
|
||||||
|
"describe from what angle the scene is filmed, incude details about camera model, lense, depth of field used to film this scene. "
|
||||||
|
"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 = {
|
data = {
|
||||||
"input": [
|
"input": [
|
||||||
{
|
{
|
||||||
|
|
@ -443,46 +453,17 @@ def describe_video_neutral(url):
|
||||||
response = bytedance_response(data)
|
response = bytedance_response(data)
|
||||||
return response["output"][1]["content"][0]["text"]
|
return response["output"][1]["content"][0]["text"]
|
||||||
|
|
||||||
def describe_video(url):
|
def describe_item(item, neutral=False):
|
||||||
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, "
|
|
||||||
"describe each objects, animal or plant, describe foreground and backgroud, "
|
|
||||||
"describe from what angle the scene is filmed, incude details about camera model, lense, depth of field used to film this scene. "
|
|
||||||
"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_item(item):
|
|
||||||
if isinstance(item, str):
|
if isinstance(item, str):
|
||||||
item = Item.objects.get(public_id=item)
|
item = Item.objects.get(public_id=item)
|
||||||
video_url = public_video_url(item)
|
return describe_video(video_url, neutral)
|
||||||
return describe_video(video_url)
|
|
||||||
|
|
||||||
|
|
||||||
def reshoot_item(item, extra_prompt=None, first_frame=None, keep=False):
|
def reshoot_item(item, extra_prompt=None, first_frame=None, keep=False):
|
||||||
if isinstance(item, str):
|
if isinstance(item, str):
|
||||||
item = Item.objects.get(public_id=item)
|
item = Item.objects.get(public_id=item)
|
||||||
duration = item.sort.duration
|
duration = item.sort.duration
|
||||||
frames = int(duration * 24)
|
frames = int(duration * 24)
|
||||||
if first_frame:
|
prompt = describe_item(item, first_frame is not None)
|
||||||
prompt = describe_item_neutral(item)
|
|
||||||
else:
|
|
||||||
prompt = describe_item(item)
|
|
||||||
|
|
||||||
if extra_prompt:
|
if extra_prompt:
|
||||||
prompt += " " + extra_prompt
|
prompt += " " + extra_prompt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue