Spaces:
Running on Zero
Running on Zero
Commit ·
902fc22
1
Parent(s): 8801ea8
longer duration
Browse files
app.py
CHANGED
|
@@ -310,7 +310,7 @@ def get_duration(rgb_image, seg_image, seed, randomize_seed,
|
|
| 310 |
cfg_interval_end, t_rescale, work_space):
|
| 311 |
instance_labels = np.unique(np.array(seg_image).reshape(-1, 3), axis=0)
|
| 312 |
step_duration = 15.0
|
| 313 |
-
return instance_labels.shape[0] * step_duration +
|
| 314 |
|
| 315 |
@spaces.GPU(duration=get_duration)
|
| 316 |
def run_generation(
|
|
@@ -324,7 +324,8 @@ def run_generation(
|
|
| 324 |
cfg_interval_end: float = 1.0,
|
| 325 |
t_rescale: float = 3.0,
|
| 326 |
work_space: dict = None,
|
| 327 |
-
):
|
|
|
|
| 328 |
if work_space is None:
|
| 329 |
raise gr.Error("Please run step 1 and step 2 first.")
|
| 330 |
required_keys = ["dir", "depth_mask", "depth", "K", "c2w", "trans", "scale"]
|
|
@@ -388,10 +389,13 @@ def run_generation(
|
|
| 388 |
run_id = str(uuid.uuid4())
|
| 389 |
|
| 390 |
DEVICE = 'cuda'
|
|
|
|
|
|
|
| 391 |
pipeline = ThreeDFixerPipeline.from_pretrained(
|
| 392 |
local_dir, compile=False
|
| 393 |
)
|
| 394 |
pipeline.to(device=DEVICE)
|
|
|
|
| 395 |
|
| 396 |
if not isinstance(rgb_image, Image.Image) and "image" in rgb_image:
|
| 397 |
rgb_image = rgb_image["image"]
|
|
@@ -644,10 +648,16 @@ def run_generation(
|
|
| 644 |
os.path.join(work_space['dir'], f"{run_id}_instance_gs_fine_{instance_name}.png")
|
| 645 |
)
|
| 646 |
|
|
|
|
|
|
|
|
|
|
| 647 |
video = render_utils.render_video(
|
| 648 |
outputs["gaussian"][0],
|
| 649 |
bg_color=(1.0, 1.0, 1.0)
|
| 650 |
)["color"]
|
|
|
|
|
|
|
|
|
|
| 651 |
imageio.mimsave(mp4_path, video, fps=30)
|
| 652 |
imageio.imwrite(poster_path, video[0])
|
| 653 |
|
|
|
|
| 310 |
cfg_interval_end, t_rescale, work_space):
|
| 311 |
instance_labels = np.unique(np.array(seg_image).reshape(-1, 3), axis=0)
|
| 312 |
step_duration = 15.0
|
| 313 |
+
return instance_labels.shape[0] * step_duration + 240
|
| 314 |
|
| 315 |
@spaces.GPU(duration=get_duration)
|
| 316 |
def run_generation(
|
|
|
|
| 324 |
cfg_interval_end: float = 1.0,
|
| 325 |
t_rescale: float = 3.0,
|
| 326 |
work_space: dict = None,
|
| 327 |
+
):
|
| 328 |
+
first_render = True
|
| 329 |
if work_space is None:
|
| 330 |
raise gr.Error("Please run step 1 and step 2 first.")
|
| 331 |
required_keys = ["dir", "depth_mask", "depth", "K", "c2w", "trans", "scale"]
|
|
|
|
| 389 |
run_id = str(uuid.uuid4())
|
| 390 |
|
| 391 |
DEVICE = 'cuda'
|
| 392 |
+
gr.Info('Loading ckpts')
|
| 393 |
+
down_t = time.time()
|
| 394 |
pipeline = ThreeDFixerPipeline.from_pretrained(
|
| 395 |
local_dir, compile=False
|
| 396 |
)
|
| 397 |
pipeline.to(device=DEVICE)
|
| 398 |
+
gr.Info(f'Loading ckpts duration: {time.time()-down_t:.2}s')
|
| 399 |
|
| 400 |
if not isinstance(rgb_image, Image.Image) and "image" in rgb_image:
|
| 401 |
rgb_image = rgb_image["image"]
|
|
|
|
| 648 |
os.path.join(work_space['dir'], f"{run_id}_instance_gs_fine_{instance_name}.png")
|
| 649 |
)
|
| 650 |
|
| 651 |
+
|
| 652 |
+
if first_render:
|
| 653 |
+
render_t = time.time()
|
| 654 |
video = render_utils.render_video(
|
| 655 |
outputs["gaussian"][0],
|
| 656 |
bg_color=(1.0, 1.0, 1.0)
|
| 657 |
)["color"]
|
| 658 |
+
if first_render:
|
| 659 |
+
gr.Info(f'Compile gsplat duration: {time.time()-render_t:.2}s')
|
| 660 |
+
first_render = False
|
| 661 |
imageio.mimsave(mp4_path, video, fps=30)
|
| 662 |
imageio.imwrite(poster_path, video[0])
|
| 663 |
|