Spaces:
Running
on
Zero
Running
on
Zero
Update gradio_app.py
Browse files- gradio_app.py +10 -2
gradio_app.py
CHANGED
|
@@ -77,6 +77,12 @@ def check_outputs_folder(folder_path):
|
|
| 77 |
else:
|
| 78 |
print(f'The folder {folder_path} does not exist.')
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
def infer(frame1_path, frame2_path):
|
| 81 |
|
| 82 |
seed = 42
|
|
@@ -96,7 +102,7 @@ def infer(frame1_path, frame2_path):
|
|
| 96 |
frame2 = load_image(frame2_path)
|
| 97 |
frame2 = frame2.resize((512, 288))
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
frames = pipe(image1=frame1, image2=frame2,
|
| 102 |
num_inference_steps=num_inference_steps, # 50
|
|
@@ -104,9 +110,11 @@ def infer(frame1_path, frame2_path):
|
|
| 104 |
weighted_average=weighted_average, # True
|
| 105 |
noise_injection_steps=noise_injection_steps, # 0
|
| 106 |
noise_injection_ratio= noise_injection_ratio, # 0.5
|
| 107 |
-
decode_chunk_size=
|
| 108 |
).frames[0]
|
| 109 |
|
|
|
|
|
|
|
| 110 |
print(f"FRAMES: {frames}")
|
| 111 |
|
| 112 |
out_dir = "result"
|
|
|
|
| 77 |
else:
|
| 78 |
print(f'The folder {folder_path} does not exist.')
|
| 79 |
|
| 80 |
+
# Custom CUDA memory management function
|
| 81 |
+
def cuda_memory_cleanup():
|
| 82 |
+
torch.cuda.empty_cache()
|
| 83 |
+
torch.cuda.ipc_collect()
|
| 84 |
+
gc.collect()
|
| 85 |
+
|
| 86 |
def infer(frame1_path, frame2_path):
|
| 87 |
|
| 88 |
seed = 42
|
|
|
|
| 102 |
frame2 = load_image(frame2_path)
|
| 103 |
frame2 = frame2.resize((512, 288))
|
| 104 |
|
| 105 |
+
cuda_memory_cleanup()
|
| 106 |
|
| 107 |
frames = pipe(image1=frame1, image2=frame2,
|
| 108 |
num_inference_steps=num_inference_steps, # 50
|
|
|
|
| 110 |
weighted_average=weighted_average, # True
|
| 111 |
noise_injection_steps=noise_injection_steps, # 0
|
| 112 |
noise_injection_ratio= noise_injection_ratio, # 0.5
|
| 113 |
+
decode_chunk_size=6
|
| 114 |
).frames[0]
|
| 115 |
|
| 116 |
+
cuda_memory_cleanup()
|
| 117 |
+
|
| 118 |
print(f"FRAMES: {frames}")
|
| 119 |
|
| 120 |
out_dir = "result"
|