Spaces:
Paused
Paused
Update web-demos/hugging_face/app.py
Browse files
web-demos/hugging_face/app.py
CHANGED
@@ -315,9 +315,9 @@ def inpaint_video(video_state, *_args):
|
|
315 |
if i not in inpaint_mask_numbers:
|
316 |
inpaint_masks[inpaint_masks == i] = 0
|
317 |
|
318 |
-
chunk_size = 30
|
319 |
-
save_size = 20
|
320 |
-
step = save_size
|
321 |
fixed_resize_ratio = 1.0
|
322 |
fixed_dilate_radius = 8
|
323 |
fixed_raft_iter = 20
|
@@ -326,6 +326,7 @@ def inpaint_video(video_state, *_args):
|
|
326 |
|
327 |
total_len = len(frames)
|
328 |
inpainted_all = []
|
|
|
329 |
|
330 |
for start in range(0, total_len, step):
|
331 |
end = min(start + chunk_size, total_len)
|
@@ -345,15 +346,29 @@ def inpaint_video(video_state, *_args):
|
|
345 |
ref_stride=fixed_ref_stride
|
346 |
)
|
347 |
|
348 |
-
|
|
|
|
|
349 |
if start == 0:
|
350 |
-
|
351 |
elif end == total_len:
|
352 |
-
|
353 |
else:
|
354 |
-
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
output_path = "./result/inpaint/{}".format(video_state["video_name"])
|
359 |
video_output = generate_video_from_frames(
|
|
|
315 |
if i not in inpaint_mask_numbers:
|
316 |
inpaint_masks[inpaint_masks == i] = 0
|
317 |
|
318 |
+
chunk_size = 30
|
319 |
+
save_size = 20
|
320 |
+
step = save_size
|
321 |
fixed_resize_ratio = 1.0
|
322 |
fixed_dilate_radius = 8
|
323 |
fixed_raft_iter = 20
|
|
|
326 |
|
327 |
total_len = len(frames)
|
328 |
inpainted_all = []
|
329 |
+
saved_indices = set()
|
330 |
|
331 |
for start in range(0, total_len, step):
|
332 |
end = min(start + chunk_size, total_len)
|
|
|
346 |
ref_stride=fixed_ref_stride
|
347 |
)
|
348 |
|
349 |
+
chunk_len = end - start
|
350 |
+
|
351 |
+
# Выбираем уникальные индексы для сохранения
|
352 |
if start == 0:
|
353 |
+
to_save = list(range(min(save_size, chunk_len)))
|
354 |
elif end == total_len:
|
355 |
+
to_save = list(range(chunk_len - (total_len - start), chunk_len))
|
356 |
else:
|
357 |
+
to_save = list(range(min(save_size, chunk_len)))
|
358 |
+
|
359 |
+
for i in to_save:
|
360 |
+
absolute_index = start + i
|
361 |
+
if absolute_index not in saved_indices:
|
362 |
+
inpainted_all.append(chunk_result[i])
|
363 |
+
saved_indices.add(absolute_index)
|
364 |
+
|
365 |
+
# 🧠 Убедимся, что длина совпадает
|
366 |
+
if len(inpainted_all) < total_len:
|
367 |
+
last_frame = inpainted_all[-1]
|
368 |
+
for _ in range(total_len - len(inpainted_all)):
|
369 |
+
inpainted_all.append(last_frame)
|
370 |
+
elif len(inpainted_all) > total_len:
|
371 |
+
inpainted_all = inpainted_all[:total_len]
|
372 |
|
373 |
output_path = "./result/inpaint/{}".format(video_state["video_name"])
|
374 |
video_output = generate_video_from_frames(
|