Spaces:
Running
on
Zero
Running
on
Zero
Update gradio_app.py
Browse files- gradio_app.py +13 -13
gradio_app.py
CHANGED
|
@@ -31,6 +31,17 @@ snapshot_download(repo_id="stabilityai/sd-vae-ft-mse", local_dir="./weights/sd-v
|
|
| 31 |
from diffueraser.diffueraser import DiffuEraser
|
| 32 |
from propainter.inference import Propainter, get_device
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Helper function to trim videos
|
| 35 |
def trim_video(input_path, output_path, max_duration=5):
|
| 36 |
clip = VideoFileClip(input_path)
|
|
@@ -39,7 +50,7 @@ def trim_video(input_path, output_path, max_duration=5):
|
|
| 39 |
clip.close()
|
| 40 |
trimmed_clip.close()
|
| 41 |
|
| 42 |
-
@spaces.GPU(duration=
|
| 43 |
def infer(input_video, input_mask):
|
| 44 |
# Setup paths and parameters
|
| 45 |
save_path = "results"
|
|
@@ -47,12 +58,7 @@ def infer(input_video, input_mask):
|
|
| 47 |
max_img_size = 960
|
| 48 |
ref_stride = 10
|
| 49 |
neighbor_length = 10
|
| 50 |
-
subvideo_length = 50
|
| 51 |
-
|
| 52 |
-
base_model_path = "weights/stable-diffusion-v1-5"
|
| 53 |
-
vae_path = "weights/sd-vae-ft-mse"
|
| 54 |
-
diffueraser_path = "weights/diffuEraser"
|
| 55 |
-
propainter_model_dir = "weights/propainter"
|
| 56 |
|
| 57 |
if not os.path.exists(save_path):
|
| 58 |
os.makedirs(save_path)
|
|
@@ -74,12 +80,6 @@ def infer(input_video, input_mask):
|
|
| 74 |
clip.close()
|
| 75 |
video_length = int(video_duration * 30)
|
| 76 |
|
| 77 |
-
# Model setup
|
| 78 |
-
device = get_device()
|
| 79 |
-
ckpt = "2-Step"
|
| 80 |
-
video_inpainting_sd = DiffuEraser(device, base_model_path, vae_path, diffueraser_path, ckpt=ckpt)
|
| 81 |
-
propainter = Propainter(propainter_model_dir, device=device)
|
| 82 |
-
|
| 83 |
# Run models
|
| 84 |
start_time = time.time()
|
| 85 |
|
|
|
|
| 31 |
from diffueraser.diffueraser import DiffuEraser
|
| 32 |
from propainter.inference import Propainter, get_device
|
| 33 |
|
| 34 |
+
base_model_path = "weights/stable-diffusion-v1-5"
|
| 35 |
+
vae_path = "weights/sd-vae-ft-mse"
|
| 36 |
+
diffueraser_path = "weights/diffuEraser"
|
| 37 |
+
propainter_model_dir = "weights/propainter"
|
| 38 |
+
|
| 39 |
+
# Model setup
|
| 40 |
+
device = get_device()
|
| 41 |
+
ckpt = "2-Step"
|
| 42 |
+
video_inpainting_sd = DiffuEraser(device, base_model_path, vae_path, diffueraser_path, ckpt=ckpt)
|
| 43 |
+
propainter = Propainter(propainter_model_dir, device=device)
|
| 44 |
+
|
| 45 |
# Helper function to trim videos
|
| 46 |
def trim_video(input_path, output_path, max_duration=5):
|
| 47 |
clip = VideoFileClip(input_path)
|
|
|
|
| 50 |
clip.close()
|
| 51 |
trimmed_clip.close()
|
| 52 |
|
| 53 |
+
@spaces.GPU(duration=120)
|
| 54 |
def infer(input_video, input_mask):
|
| 55 |
# Setup paths and parameters
|
| 56 |
save_path = "results"
|
|
|
|
| 58 |
max_img_size = 960
|
| 59 |
ref_stride = 10
|
| 60 |
neighbor_length = 10
|
| 61 |
+
subvideo_length = 50
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
if not os.path.exists(save_path):
|
| 64 |
os.makedirs(save_path)
|
|
|
|
| 80 |
clip.close()
|
| 81 |
video_length = int(video_duration * 30)
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
# Run models
|
| 84 |
start_time = time.time()
|
| 85 |
|