fixes
This commit is contained in:
parent
06e099e797
commit
55bfb769cd
1 changed files with 31 additions and 7 deletions
38
generate.py
38
generate.py
|
|
@ -575,11 +575,15 @@ def replace_character_motion_control(item, character, keep=False):
|
|||
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:
|
||||
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, "
|
||||
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 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>. "
|
||||
|
|
@ -616,15 +620,15 @@ def describe_item(item, neutral=False):
|
|||
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):
|
||||
item = Item.objects.get(public_id=item)
|
||||
if isinstance(first_frame, Document):
|
||||
first_frame = public_document_url(first_frame)
|
||||
duration = item.sort.duration
|
||||
frames = int(duration * 24)
|
||||
prompt = describe_item(item, first_frame is not None)
|
||||
|
||||
if prompt is None:
|
||||
prompt = describe_item(item, first_frame is not None)
|
||||
if extra_prompt:
|
||||
prompt += " " + extra_prompt
|
||||
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["seed"] = seed
|
||||
ai.save()
|
||||
if not keep:
|
||||
shutil.rmtree(os.path.dirname(joined_output))
|
||||
for first_frame in first_frames:
|
||||
first_frame.add(ai)
|
||||
if not keep:
|
||||
|
|
@ -1146,6 +1148,7 @@ def process_motion_firstframe(character="P1", keep=False):
|
|||
try:
|
||||
replace_character_motion_control(i, character, keep=keep)
|
||||
except:
|
||||
i.refresh_from_db()
|
||||
add_tag(i, 'ai-failed')
|
||||
print('>> failed', i)
|
||||
|
||||
|
|
@ -1159,10 +1162,31 @@ def extract_firstframe(character='P1'):
|
|||
try:
|
||||
first_frame = replace_character(item, character, 0)
|
||||
except:
|
||||
item.refresh_from_db()
|
||||
add_tag(item, 'ai-failed')
|
||||
|
||||
def process_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():
|
||||
if i.sort.duration > 30: continue
|
||||
if i.public_id == 'HZ': continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue