wbhu-tc commited on
Commit
4eabd3c
1 Parent(s): 80e9952
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
 
3
  import numpy as np
@@ -16,7 +17,11 @@ from huggingface_hub import hf_hub_download
16
  from depthcrafter.utils import read_video_frames, vis_sequence_depth, save_video
17
 
18
  examples = [
19
- ["examples/example_01.mp4", 25, 1.2, 1024, 195],
 
 
 
 
20
  ]
21
 
22
 
@@ -83,6 +88,11 @@ def infer_depth(
83
  save_video(res, save_path + "_depth.mp4", fps=target_fps)
84
  save_video(vis, save_path + "_vis.mp4", fps=target_fps)
85
  save_video(frames, save_path + "_input.mp4", fps=target_fps)
 
 
 
 
 
86
  return [
87
  save_path + "_input.mp4",
88
  save_path + "_vis.mp4",
@@ -106,7 +116,7 @@ def construct_demo():
106
  <a href='https://scholar.google.com/citations?user=4oXBp9UAAAAJ&hl=en'>Ying Shan</a>\
107
  </h2> \
108
  <a style='font-size:18px;color: #000000'>If you find DepthCrafter useful, please help ⭐ the </a>\
109
- <a style='font-size:18px;color: #FF5DB0' href='https://github.com/wbhu/DepthCrafter'>[Github Repo]</a>\
110
  <a style='font-size:18px;color: #000000'>, which is important to Open-Source projects. Thanks!</a>\
111
  <a style='font-size:18px;color: #000000' href='https://arxiv.org/abs/2409.02095'> [ArXiv] </a>\
112
  <a style='font-size:18px;color: #000000' href='https://depthcrafter.github.io/'> [Project Page] </a> </div>
@@ -145,7 +155,7 @@ def construct_demo():
145
  label="num denoising steps",
146
  minimum=1,
147
  maximum=25,
148
- value=25,
149
  step=1,
150
  )
151
  guidance_scale = gr.Slider(
@@ -166,7 +176,7 @@ def construct_demo():
166
  label="process length",
167
  minimum=1,
168
  maximum=280,
169
- value=195,
170
  step=1,
171
  )
172
  generate_btn = gr.Button("Generate")
@@ -184,7 +194,18 @@ def construct_demo():
184
  ],
185
  outputs=[output_video_1, output_video_2],
186
  fn=infer_depth,
187
- cache_examples=False,
 
 
 
 
 
 
 
 
 
 
 
188
  )
189
 
190
  generate_btn.click(
 
1
+ import gc
2
  import os
3
 
4
  import numpy as np
 
17
  from depthcrafter.utils import read_video_frames, vis_sequence_depth, save_video
18
 
19
  examples = [
20
+ ["examples/example_01.mp4", 10, 1.2, 1024, 60],
21
+ ["examples/example_02.mp4", 10, 1.2, 1024, 60],
22
+ ["examples/example_03.mp4", 10, 1.2, 1024, 60],
23
+ ["examples/example_04.mp4", 10, 1.2, 1024, 60],
24
+ ["examples/example_05.mp4", 10, 1.2, 1024, 60],
25
  ]
26
 
27
 
 
88
  save_video(res, save_path + "_depth.mp4", fps=target_fps)
89
  save_video(vis, save_path + "_vis.mp4", fps=target_fps)
90
  save_video(frames, save_path + "_input.mp4", fps=target_fps)
91
+
92
+ # clear the cache for the next video
93
+ gc.collect()
94
+ torch.cuda.empty_cache()
95
+
96
  return [
97
  save_path + "_input.mp4",
98
  save_path + "_vis.mp4",
 
116
  <a href='https://scholar.google.com/citations?user=4oXBp9UAAAAJ&hl=en'>Ying Shan</a>\
117
  </h2> \
118
  <a style='font-size:18px;color: #000000'>If you find DepthCrafter useful, please help ⭐ the </a>\
119
+ <a style='font-size:18px;color: #FF5DB0' href='https://github.com/Tencent/DepthCrafter'>[Github Repo]</a>\
120
  <a style='font-size:18px;color: #000000'>, which is important to Open-Source projects. Thanks!</a>\
121
  <a style='font-size:18px;color: #000000' href='https://arxiv.org/abs/2409.02095'> [ArXiv] </a>\
122
  <a style='font-size:18px;color: #000000' href='https://depthcrafter.github.io/'> [Project Page] </a> </div>
 
155
  label="num denoising steps",
156
  minimum=1,
157
  maximum=25,
158
+ value=10,
159
  step=1,
160
  )
161
  guidance_scale = gr.Slider(
 
176
  label="process length",
177
  minimum=1,
178
  maximum=280,
179
+ value=60,
180
  step=1,
181
  )
182
  generate_btn = gr.Button("Generate")
 
194
  ],
195
  outputs=[output_video_1, output_video_2],
196
  fn=infer_depth,
197
+ cache_examples=True,
198
+ )
199
+ gr.Markdown(
200
+ """
201
+ <span style='font-size:18px;color: #E7CCCC'>Note:
202
+ For time quota consideration, we set the default parameters to be more efficient here,
203
+ with a trade-off of shorter video length and slightly lower quality.
204
+ You may adjust the parameters according to our
205
+ <a style='font-size:18px;color: #FF5DB0' href='https://github.com/Tencent/DepthCrafter'>[Github Repo]</a>
206
+ for better results if you have enough time quota.
207
+ </span>
208
+ """
209
  )
210
 
211
  generate_btn.click(
examples/example_01.mp4 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:afb78decc210225793b20d5bca5b13da07c97233e6fabea44bf02eba8a52bdaf
3
- size 14393250
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99252cdff428d17b2f3348f4b5ab8951a209f87dd1a2cd924c5d4e257825fdc3
3
+ size 803640
examples/example_02.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cadcf18e00165d10aeac49b4d86f3dfb876b4cea07c1717f5f56db5160dbc2c
3
+ size 5714915
examples/example_03.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7b7f118a1b5b0642cdeb23a3ba7fbff917c42f50312c752d166738de578c586
3
+ size 447055
examples/example_04.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d91a3fc591e93eb31b640f81d8ed1ff051d4a66bd1a38b36f2cf7e9ebcbd9073
3
+ size 1171671
examples/example_05.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5625e308eb9a2bc2332f38c936e5bd4b5aeff70d6527aa8005a9a167d3c08db
3
+ size 2324988