Spaces:
Running
on
Zero
Running
on
Zero
IceClear
commited on
Commit
·
f9ea190
1
Parent(s):
6cbcc74
update
Browse files
app.py
CHANGED
|
@@ -124,9 +124,9 @@ torch.hub.download_url_to_file(
|
|
| 124 |
'https://huggingface.co/datasets/Iceclear/SeedVR_VideoDemos/resolve/main/seedvr_videos_crf23/aigc1k/2_1_lq.mp4',
|
| 125 |
'03.mp4')
|
| 126 |
|
| 127 |
-
def configure_sequence_parallel(sp_size):
|
| 128 |
-
|
| 129 |
-
|
| 130 |
|
| 131 |
@spaces.GPU(duration=120)
|
| 132 |
def configure_runner(sp_size):
|
|
@@ -135,8 +135,8 @@ def configure_runner(sp_size):
|
|
| 135 |
runner = VideoDiffusionInfer(config)
|
| 136 |
OmegaConf.set_readonly(runner.config, False)
|
| 137 |
|
| 138 |
-
init_torch(cudnn_benchmark=False, timeout=datetime.timedelta(seconds=3600))
|
| 139 |
-
configure_sequence_parallel(sp_size)
|
| 140 |
runner.configure_dit_model(device="cuda", checkpoint='./ckpts/seedvr_ema_3b.pth')
|
| 141 |
runner.configure_vae_model()
|
| 142 |
# Set memory limit.
|
|
@@ -279,14 +279,9 @@ def generation_loop(video_path='./test_videos', output_dir='./results', seed=666
|
|
| 279 |
original_videos, _, _ = _build_test_prompts(video_path)
|
| 280 |
|
| 281 |
# divide the prompts into different groups
|
| 282 |
-
original_videos_group =
|
| 283 |
-
original_videos,
|
| 284 |
-
get_data_parallel_world_size() // get_sequence_parallel_world_size(),
|
| 285 |
-
)
|
| 286 |
# store prompt mapping
|
| 287 |
-
original_videos_local = original_videos_group
|
| 288 |
-
get_data_parallel_rank() // get_sequence_parallel_world_size()
|
| 289 |
-
]
|
| 290 |
original_videos_local = partition_by_size(original_videos_local, batch_size)
|
| 291 |
|
| 292 |
# pre-extract the text embeddings
|
|
@@ -345,32 +340,31 @@ def generation_loop(video_path='./test_videos', output_dir='./results', seed=666
|
|
| 345 |
del cond_latents
|
| 346 |
|
| 347 |
# dump samples to the output directory
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
input
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
sample
|
| 363 |
-
sample.to("cpu"), input[: sample.size(0)].to("cpu")
|
| 364 |
-
)
|
| 365 |
-
else:
|
| 366 |
-
sample = sample.to("cpu")
|
| 367 |
-
sample = (
|
| 368 |
-
rearrange(sample[:, None], "t c h w -> t h w c")
|
| 369 |
-
if sample.ndim == 3
|
| 370 |
-
else rearrange(sample, "t c h w -> t h w c")
|
| 371 |
)
|
| 372 |
-
|
| 373 |
-
sample = sample.to(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
|
| 375 |
gc.collect()
|
| 376 |
torch.cuda.empty_cache()
|
|
|
|
| 124 |
'https://huggingface.co/datasets/Iceclear/SeedVR_VideoDemos/resolve/main/seedvr_videos_crf23/aigc1k/2_1_lq.mp4',
|
| 125 |
'03.mp4')
|
| 126 |
|
| 127 |
+
# def configure_sequence_parallel(sp_size):
|
| 128 |
+
# if sp_size > 1:
|
| 129 |
+
# init_sequence_parallel(sp_size)
|
| 130 |
|
| 131 |
@spaces.GPU(duration=120)
|
| 132 |
def configure_runner(sp_size):
|
|
|
|
| 135 |
runner = VideoDiffusionInfer(config)
|
| 136 |
OmegaConf.set_readonly(runner.config, False)
|
| 137 |
|
| 138 |
+
# init_torch(cudnn_benchmark=False, timeout=datetime.timedelta(seconds=3600))
|
| 139 |
+
# configure_sequence_parallel(sp_size)
|
| 140 |
runner.configure_dit_model(device="cuda", checkpoint='./ckpts/seedvr_ema_3b.pth')
|
| 141 |
runner.configure_vae_model()
|
| 142 |
# Set memory limit.
|
|
|
|
| 279 |
original_videos, _, _ = _build_test_prompts(video_path)
|
| 280 |
|
| 281 |
# divide the prompts into different groups
|
| 282 |
+
original_videos_group = original_videos
|
|
|
|
|
|
|
|
|
|
| 283 |
# store prompt mapping
|
| 284 |
+
original_videos_local = original_videos_group
|
|
|
|
|
|
|
| 285 |
original_videos_local = partition_by_size(original_videos_local, batch_size)
|
| 286 |
|
| 287 |
# pre-extract the text embeddings
|
|
|
|
| 340 |
del cond_latents
|
| 341 |
|
| 342 |
# dump samples to the output directory
|
| 343 |
+
for path, input, sample, ori_length in zip(
|
| 344 |
+
videos, input_videos, samples, ori_lengths
|
| 345 |
+
):
|
| 346 |
+
if ori_length < sample.shape[0]:
|
| 347 |
+
sample = sample[:ori_length]
|
| 348 |
+
filename = os.path.join(tgt_path, os.path.basename(path))
|
| 349 |
+
# color fix
|
| 350 |
+
input = (
|
| 351 |
+
rearrange(input[:, None], "c t h w -> t c h w")
|
| 352 |
+
if input.ndim == 3
|
| 353 |
+
else rearrange(input, "c t h w -> t c h w")
|
| 354 |
+
)
|
| 355 |
+
if use_colorfix:
|
| 356 |
+
sample = wavelet_reconstruction(
|
| 357 |
+
sample.to("cpu"), input[: sample.size(0)].to("cpu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
)
|
| 359 |
+
else:
|
| 360 |
+
sample = sample.to("cpu")
|
| 361 |
+
sample = (
|
| 362 |
+
rearrange(sample[:, None], "t c h w -> t h w c")
|
| 363 |
+
if sample.ndim == 3
|
| 364 |
+
else rearrange(sample, "t c h w -> t h w c")
|
| 365 |
+
)
|
| 366 |
+
sample = sample.clip(-1, 1).mul_(0.5).add_(0.5).mul_(255).round()
|
| 367 |
+
sample = sample.to(torch.uint8).numpy()
|
| 368 |
|
| 369 |
gc.collect()
|
| 370 |
torch.cuda.empty_cache()
|