Update app.py
Browse files
app.py
CHANGED
|
@@ -38,8 +38,9 @@ def generate(input_video):
|
|
| 38 |
temp_dir = tempfile.mkdtemp()
|
| 39 |
|
| 40 |
workdir = temp_dir
|
| 41 |
-
|
| 42 |
-
|
|
|
|
| 43 |
test_path = input_video
|
| 44 |
|
| 45 |
try:
|
|
@@ -48,20 +49,19 @@ def generate(input_video):
|
|
| 48 |
[
|
| 49 |
"python", "infer_3d.py", "big",
|
| 50 |
"--workspace", f"{workdir}",
|
| 51 |
-
"--resume", f"{
|
|
|
|
| 52 |
"--num_frames", f"{num_frames}",
|
| 53 |
"--test_path", f"{test_path}",
|
| 54 |
],
|
| 55 |
check=True
|
| 56 |
)
|
| 57 |
|
| 58 |
-
|
| 59 |
-
# Retrieve the file name without the extension
|
| 60 |
-
#removed_bg_file_name = os.path.splitext(os.path.basename(removed_bg_path))[0]
|
| 61 |
output_videos = glob(os.path.join(f"{workdir}", "*.mp4"))
|
| 62 |
return output_videos[0]
|
|
|
|
| 63 |
except subprocess.CalledProcessError as e:
|
| 64 |
-
|
| 65 |
|
| 66 |
with gr.Blocks() as demo:
|
| 67 |
with gr.Column():
|
|
|
|
| 38 |
temp_dir = tempfile.mkdtemp()
|
| 39 |
|
| 40 |
workdir = temp_dir
|
| 41 |
+
recon_model = "pretrained/recon.safetensors"
|
| 42 |
+
interp_model = "pretrained/interp.safetensors"
|
| 43 |
+
num_frames = 16
|
| 44 |
test_path = input_video
|
| 45 |
|
| 46 |
try:
|
|
|
|
| 49 |
[
|
| 50 |
"python", "infer_3d.py", "big",
|
| 51 |
"--workspace", f"{workdir}",
|
| 52 |
+
"--resume", f"{recon_model}",
|
| 53 |
+
"--interpresume", f"{interp_model}",
|
| 54 |
"--num_frames", f"{num_frames}",
|
| 55 |
"--test_path", f"{test_path}",
|
| 56 |
],
|
| 57 |
check=True
|
| 58 |
)
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
output_videos = glob(os.path.join(f"{workdir}", "*.mp4"))
|
| 61 |
return output_videos[0]
|
| 62 |
+
|
| 63 |
except subprocess.CalledProcessError as e:
|
| 64 |
+
raise gr.Error(f"Error during inference: {str(e)}")
|
| 65 |
|
| 66 |
with gr.Blocks() as demo:
|
| 67 |
with gr.Column():
|