Spaces:
Runtime error
Runtime error
add multi gpu logic
Browse files- app.py +12 -7
- t2v_enhanced/model_func.py +1 -1
app.py
CHANGED
|
@@ -29,8 +29,11 @@ args = parser.parse_args()
|
|
| 29 |
Path(args.where_to_log).mkdir(parents=True, exist_ok=True)
|
| 30 |
result_fol = Path(args.where_to_log).absolute()
|
| 31 |
device = args.device
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 34 |
# --------------------------
|
| 35 |
# ----- Configurations -----
|
| 36 |
# --------------------------
|
|
@@ -40,15 +43,15 @@ cfg_v2v = {'downscale': 1, 'upscale_size': (1280, 720), 'model_id': 'damo/Video-
|
|
| 40 |
# --------------------------
|
| 41 |
# ----- Initialization -----
|
| 42 |
# --------------------------
|
| 43 |
-
ms_model = init_modelscope(
|
| 44 |
# # zs_model = init_zeroscope(device)
|
| 45 |
-
ad_model = init_animatediff(
|
| 46 |
-
svd_model = init_svd(
|
| 47 |
-
sdxl_model = init_sdxl(
|
| 48 |
|
| 49 |
ckpt_file_streaming_t2v = Path("t2v_enhanced/checkpoints/streaming_t2v.ckpt").absolute()
|
| 50 |
stream_cli, stream_model = init_streamingt2v_model(ckpt_file_streaming_t2v, result_fol)
|
| 51 |
-
msxl_model = init_v2v_model(cfg_v2v,
|
| 52 |
|
| 53 |
|
| 54 |
|
|
@@ -91,6 +94,8 @@ def enhance(prompt, input_to_enhance, num_frames=None, image=None, model_name_st
|
|
| 91 |
if input_to_enhance is None:
|
| 92 |
input_to_enhance = generate(prompt, num_frames, image, model_name_stage1, model_name_stage2, seed, t, image_guidance)
|
| 93 |
encoded_video = video2video(prompt, input_to_enhance, result_fol, cfg_v2v, msxl_model)
|
|
|
|
|
|
|
| 94 |
return encoded_video
|
| 95 |
|
| 96 |
def change_visibility(value):
|
|
|
|
| 29 |
Path(args.where_to_log).mkdir(parents=True, exist_ok=True)
|
| 30 |
result_fol = Path(args.where_to_log).absolute()
|
| 31 |
device = args.device
|
| 32 |
+
n_devices = int(os.environ.get('NDEVICES', 4))
|
| 33 |
+
if n_devices == 4:
|
| 34 |
+
devices = [f"cuda:{idx}" for idx in range(4)]
|
| 35 |
+
else:
|
| 36 |
+
devices = ["cuda"] * 4
|
| 37 |
# --------------------------
|
| 38 |
# ----- Configurations -----
|
| 39 |
# --------------------------
|
|
|
|
| 43 |
# --------------------------
|
| 44 |
# ----- Initialization -----
|
| 45 |
# --------------------------
|
| 46 |
+
ms_model = init_modelscope(devices[1])
|
| 47 |
# # zs_model = init_zeroscope(device)
|
| 48 |
+
ad_model = init_animatediff(devices[1])
|
| 49 |
+
svd_model = init_svd(devices[2])
|
| 50 |
+
sdxl_model = init_sdxl(devices[2])
|
| 51 |
|
| 52 |
ckpt_file_streaming_t2v = Path("t2v_enhanced/checkpoints/streaming_t2v.ckpt").absolute()
|
| 53 |
stream_cli, stream_model = init_streamingt2v_model(ckpt_file_streaming_t2v, result_fol)
|
| 54 |
+
msxl_model = init_v2v_model(cfg_v2v, devices[3])
|
| 55 |
|
| 56 |
|
| 57 |
|
|
|
|
| 94 |
if input_to_enhance is None:
|
| 95 |
input_to_enhance = generate(prompt, num_frames, image, model_name_stage1, model_name_stage2, seed, t, image_guidance)
|
| 96 |
encoded_video = video2video(prompt, input_to_enhance, result_fol, cfg_v2v, msxl_model)
|
| 97 |
+
# for idx in range(4):
|
| 98 |
+
# print(f">>> cuda:{idx}", torch.cuda.max_memory_allocated(f"cuda:{idx}"))
|
| 99 |
return encoded_video
|
| 100 |
|
| 101 |
def change_visibility(value):
|
t2v_enhanced/model_func.py
CHANGED
|
@@ -66,7 +66,7 @@ def svd_short_gen(image, prompt, svd_model, sdxl_model, inference_generator, t=2
|
|
| 66 |
image = center_crop(image)
|
| 67 |
image = add_margin(image, 0, 224, 0, 224, (0, 0, 0))
|
| 68 |
|
| 69 |
-
frames = svd_model(image, decode_chunk_size=
|
| 70 |
frames = torch.stack([transform(frame) for frame in frames])
|
| 71 |
frames = frames.to(device).to(torch.float32)
|
| 72 |
frames = frames[:16,:,:,224:-224]
|
|
|
|
| 66 |
image = center_crop(image)
|
| 67 |
image = add_margin(image, 0, 224, 0, 224, (0, 0, 0))
|
| 68 |
|
| 69 |
+
frames = svd_model(image, decode_chunk_size=4, generator=inference_generator).frames[0]
|
| 70 |
frames = torch.stack([transform(frame) for frame in frames])
|
| 71 |
frames = frames.to(device).to(torch.float32)
|
| 72 |
frames = frames[:16,:,:,224:-224]
|