Update app.py
Browse files
app.py
CHANGED
|
@@ -68,9 +68,33 @@ def generate(input_video):
|
|
| 68 |
check=True
|
| 69 |
)
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
except subprocess.CalledProcessError as e:
|
| 76 |
raise gr.Error(f"Error during inference: {str(e)}")
|
|
@@ -78,7 +102,7 @@ def generate(input_video):
|
|
| 78 |
with gr.Blocks() as demo:
|
| 79 |
with gr.Column():
|
| 80 |
gr.Markdown("# L4GM: Large 4D Gaussian Reconstruction Model")
|
| 81 |
-
|
| 82 |
<div style="display:flex;column-gap:4px;">
|
| 83 |
<a href="https://github.com/nv-tlabs/L4GM-official/tree/main">
|
| 84 |
<img src='https://img.shields.io/badge/GitHub-Repo-blue'>
|
|
@@ -96,7 +120,7 @@ with gr.Blocks() as demo:
|
|
| 96 |
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/follow-me-on-HF-sm-dark.svg" alt="Follow me on HF">
|
| 97 |
</a>
|
| 98 |
</div>
|
| 99 |
-
|
| 100 |
with gr.Row():
|
| 101 |
with gr.Column():
|
| 102 |
input_video = gr.Video(label="Input Video", interactive=False)
|
|
|
|
| 68 |
check=True
|
| 69 |
)
|
| 70 |
|
| 71 |
+
# Get all .mp4 files in the workdir
|
| 72 |
+
output_videos = glob(os.path.join(workdir, "*.mp4"))
|
| 73 |
+
print("Found videos:", output_videos)
|
| 74 |
+
|
| 75 |
+
# Check if the 5th video exists
|
| 76 |
+
if len(output_videos) < 5:
|
| 77 |
+
raise IndexError("Less than 5 .mp4 files found in the workdir.")
|
| 78 |
+
|
| 79 |
+
# Get the 5th video
|
| 80 |
+
selected_video = output_videos[4]
|
| 81 |
+
print("Selected video:", selected_video)
|
| 82 |
+
|
| 83 |
+
# Create a new temporary directory
|
| 84 |
+
temp_dir = tempfile.mkdtemp()
|
| 85 |
+
print("Temporary directory created:", temp_dir)
|
| 86 |
+
|
| 87 |
+
# Copy the selected video to the temporary directory
|
| 88 |
+
new_video_path = os.path.join(temp_dir, os.path.basename(selected_video))
|
| 89 |
+
shutil.copy(selected_video, new_video_path)
|
| 90 |
+
print(f"Copied {selected_video} to {new_video_path}")
|
| 91 |
+
|
| 92 |
+
# Delete the workdir folder
|
| 93 |
+
shutil.rmtree(workdir)
|
| 94 |
+
print(f"Deleted workdir: {workdir}")
|
| 95 |
+
|
| 96 |
+
# Return the new path of the copied video
|
| 97 |
+
return new_video_path
|
| 98 |
|
| 99 |
except subprocess.CalledProcessError as e:
|
| 100 |
raise gr.Error(f"Error during inference: {str(e)}")
|
|
|
|
| 102 |
with gr.Blocks() as demo:
|
| 103 |
with gr.Column():
|
| 104 |
gr.Markdown("# L4GM: Large 4D Gaussian Reconstruction Model")
|
| 105 |
+
gr.HTML("""
|
| 106 |
<div style="display:flex;column-gap:4px;">
|
| 107 |
<a href="https://github.com/nv-tlabs/L4GM-official/tree/main">
|
| 108 |
<img src='https://img.shields.io/badge/GitHub-Repo-blue'>
|
|
|
|
| 120 |
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/follow-me-on-HF-sm-dark.svg" alt="Follow me on HF">
|
| 121 |
</a>
|
| 122 |
</div>
|
| 123 |
+
""")
|
| 124 |
with gr.Row():
|
| 125 |
with gr.Column():
|
| 126 |
input_video = gr.Video(label="Input Video", interactive=False)
|