fixes
This commit is contained in:
parent
06e099e797
commit
55bfb769cd
1 changed files with 31 additions and 7 deletions
36
generate.py
36
generate.py
|
|
@ -575,11 +575,15 @@ def replace_character_motion_control(item, character, keep=False):
|
||||||
return ai
|
return ai
|
||||||
|
|
||||||
|
|
||||||
def describe_video(url, neutral=False):
|
def describe_video(url, neutral=False, face=False):
|
||||||
|
if face:
|
||||||
|
extra = 'describe the facial expression to allow an actor to recreate the scene, '
|
||||||
|
else:
|
||||||
|
extra = ''
|
||||||
if neutral:
|
if neutral:
|
||||||
prompt = (
|
prompt = (
|
||||||
"Detect cuts or scene changes and describe each scene, use as much details as you can. "
|
"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, "
|
f"Describe each person incudling detalied apreance, haircut in a gender neutral way, {extra}"
|
||||||
"describe each objects, animal or plant, describe foreground and backgroud, "
|
"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. "
|
"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>. "
|
"Use the format: <description of scene 1>. CAMERA CUT TO <description of scene 2>. CAMERA CUT TO <description of scene 3>. "
|
||||||
|
|
@ -616,15 +620,15 @@ def describe_item(item, neutral=False):
|
||||||
return describe_video(video_url, neutral)
|
return describe_video(video_url, neutral)
|
||||||
|
|
||||||
|
|
||||||
def reshoot_item(item, extra_prompt=None, first_frame=None, keep=False):
|
def reshoot_item(item, extra_prompt=None, first_frame=None, keep=False, prompt=None):
|
||||||
if isinstance(item, str):
|
if isinstance(item, str):
|
||||||
item = Item.objects.get(public_id=item)
|
item = Item.objects.get(public_id=item)
|
||||||
if isinstance(first_frame, Document):
|
if isinstance(first_frame, Document):
|
||||||
first_frame = public_document_url(first_frame)
|
first_frame = public_document_url(first_frame)
|
||||||
duration = item.sort.duration
|
duration = item.sort.duration
|
||||||
frames = int(duration * 24)
|
frames = int(duration * 24)
|
||||||
|
if prompt is None:
|
||||||
prompt = describe_item(item, first_frame is not None)
|
prompt = describe_item(item, first_frame is not None)
|
||||||
|
|
||||||
if extra_prompt:
|
if extra_prompt:
|
||||||
prompt += " " + extra_prompt
|
prompt += " " + extra_prompt
|
||||||
prompt_hash = hashlib.sha1((prompt).encode()).hexdigest()
|
prompt_hash = hashlib.sha1((prompt).encode()).hexdigest()
|
||||||
|
|
@ -719,8 +723,6 @@ def reshoot_item_segments(item, character, keep=False):
|
||||||
ai.data["model"] = status["model"]
|
ai.data["model"] = status["model"]
|
||||||
ai.data["seed"] = seed
|
ai.data["seed"] = seed
|
||||||
ai.save()
|
ai.save()
|
||||||
if not keep:
|
|
||||||
shutil.rmtree(os.path.dirname(joined_output))
|
|
||||||
for first_frame in first_frames:
|
for first_frame in first_frames:
|
||||||
first_frame.add(ai)
|
first_frame.add(ai)
|
||||||
if not keep:
|
if not keep:
|
||||||
|
|
@ -1146,6 +1148,7 @@ def process_motion_firstframe(character="P1", keep=False):
|
||||||
try:
|
try:
|
||||||
replace_character_motion_control(i, character, keep=keep)
|
replace_character_motion_control(i, character, keep=keep)
|
||||||
except:
|
except:
|
||||||
|
i.refresh_from_db()
|
||||||
add_tag(i, 'ai-failed')
|
add_tag(i, 'ai-failed')
|
||||||
print('>> failed', i)
|
print('>> failed', i)
|
||||||
|
|
||||||
|
|
@ -1159,10 +1162,31 @@ def extract_firstframe(character='P1'):
|
||||||
try:
|
try:
|
||||||
first_frame = replace_character(item, character, 0)
|
first_frame = replace_character(item, character, 0)
|
||||||
except:
|
except:
|
||||||
|
item.refresh_from_db()
|
||||||
add_tag(item, 'ai-failed')
|
add_tag(item, 'ai-failed')
|
||||||
|
|
||||||
def process_reshoot_firstframe():
|
def process_reshoot_firstframe():
|
||||||
l = itemlist.models.List.objects.get(name='Reshoot-Firstframe')
|
l = itemlist.models.List.objects.get(name='Reshoot-Firstframe')
|
||||||
|
for i in l.items.all():
|
||||||
|
if i.sort.duration > 30: continue
|
||||||
|
if i.public_id == 'HZ': continue
|
||||||
|
if i.documents.all().count():
|
||||||
|
ai = Item.objects.filter(data__type__icontains='ai').filter(data__title=i.data['title'])
|
||||||
|
if ai.exists() or 'ai-failed' in i.data.get('tags', []):
|
||||||
|
print('>> skip', i)
|
||||||
|
continue
|
||||||
|
first_frame = i.documents.all().order_by('-created').first()
|
||||||
|
if not first_frame:
|
||||||
|
first_frame = replace_character(i, 'P1', 0)
|
||||||
|
print(i, first_frame, i.documents.all().count())
|
||||||
|
try:
|
||||||
|
reshoot_item(i, first_frame=first_frame)
|
||||||
|
except:
|
||||||
|
add_tag(i, 'ai-failed')
|
||||||
|
print('>> failed', i)
|
||||||
|
|
||||||
|
def process_motion_firstframe():
|
||||||
|
l = itemlist.models.List.objects.get(name='Motion-Firstframe')
|
||||||
for i in l.items.all():
|
for i in l.items.all():
|
||||||
if i.sort.duration > 30: continue
|
if i.sort.duration > 30: continue
|
||||||
if i.public_id == 'HZ': continue
|
if i.public_id == 'HZ': continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue