Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ from typing import Any, Union
|
|
9 |
import numpy as np
|
10 |
import torch
|
11 |
import uuid
|
|
|
12 |
|
13 |
print(f'torch version:{torch.__version__}')
|
14 |
|
@@ -99,7 +100,29 @@ def first_file_from_dir(directory, ext):
|
|
99 |
files = glob.glob(os.path.join(directory, f"*.{ext}"))
|
100 |
return sorted(files)[0] if files else None
|
101 |
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
@torch.no_grad()
|
104 |
def run_triposg(image_path: str,
|
105 |
num_parts: int = 1,
|
|
|
9 |
import numpy as np
|
10 |
import torch
|
11 |
import uuid
|
12 |
+
import shutil
|
13 |
|
14 |
print(f'torch version:{torch.__version__}')
|
15 |
|
|
|
100 |
files = glob.glob(os.path.join(directory, f"*.{ext}"))
|
101 |
return sorted(files)[0] if files else None
|
102 |
|
103 |
+
def get_duration(
|
104 |
+
image_path,
|
105 |
+
num_parts,
|
106 |
+
seed,
|
107 |
+
num_tokens,
|
108 |
+
num_inference_steps,
|
109 |
+
guidance_scale,
|
110 |
+
use_flash_decoder,
|
111 |
+
rmbg,
|
112 |
+
session_id,
|
113 |
+
progress,
|
114 |
+
):
|
115 |
+
|
116 |
+
duration_seconds = 60
|
117 |
+
|
118 |
+
if num_parts > 5:
|
119 |
+
duration_seconds = 75
|
120 |
+
elif num_parts > 10:
|
121 |
+
duration_seconds = 90
|
122 |
+
return int(duration_seconds)
|
123 |
+
|
124 |
+
|
125 |
+
@spaces.GPU(duration=get_duration)
|
126 |
@torch.no_grad()
|
127 |
def run_triposg(image_path: str,
|
128 |
num_parts: int = 1,
|