simplify
Browse files
app.py
CHANGED
@@ -115,7 +115,7 @@ def explode_mesh(mesh: trimesh.Scene, explode_factor: float = 0.5):
|
|
115 |
|
116 |
|
117 |
@spaces.GPU(duration=600)
|
118 |
-
def run_full(data_path, seed=42, num_inference_steps=25, guidance_scale=3.5, progress=gr.Progress(track_tqdm=True)):
|
119 |
|
120 |
batch_size = 30
|
121 |
parts_data = prepare_data(data_path)
|
@@ -148,38 +148,6 @@ def visualize_input(mesh_in):
|
|
148 |
return mesh_in
|
149 |
|
150 |
|
151 |
-
@spaces.GPU(duration=600)
|
152 |
-
def run_example(data_path: str, example_image, seed=42, num_inference_steps=25, guidance_scale=3.5):
|
153 |
-
|
154 |
-
batch_size = 30
|
155 |
-
parts_data = prepare_data(data_path)
|
156 |
-
|
157 |
-
part_scene = run_holopart(
|
158 |
-
holopart_pipe,
|
159 |
-
batch=parts_data,
|
160 |
-
batch_size=batch_size,
|
161 |
-
seed=seed,
|
162 |
-
num_inference_steps=num_inference_steps,
|
163 |
-
guidance_scale=guidance_scale,
|
164 |
-
num_chunks=1000000,
|
165 |
-
)
|
166 |
-
print("mesh extraction done")
|
167 |
-
|
168 |
-
|
169 |
-
save_dir = os.path.join(TMP_DIR, "examples")
|
170 |
-
os.makedirs(save_dir, exist_ok=True)
|
171 |
-
mesh_path = os.path.join(save_dir, f"holorpart_{get_random_hex()}.glb")
|
172 |
-
part_scene.export(mesh_path)
|
173 |
-
print("save to ", mesh_path)
|
174 |
-
exploded_mesh = explode_mesh(part_scene, 0.5)
|
175 |
-
exploded_mesh_path = os.path.join(save_dir, f"holorpart_exploded_{get_random_hex()}.glb")
|
176 |
-
exploded_mesh.export(exploded_mesh_path)
|
177 |
-
|
178 |
-
torch.cuda.empty_cache()
|
179 |
-
|
180 |
-
return mesh_path, exploded_mesh_path
|
181 |
-
|
182 |
-
|
183 |
with gr.Blocks(title="HoloPart") as demo:
|
184 |
gr.Markdown(HEADER)
|
185 |
|
@@ -232,10 +200,11 @@ with gr.Blocks(title="HoloPart") as demo:
|
|
232 |
with gr.Row():
|
233 |
examples = gr.Examples(
|
234 |
examples=EXAMPLES,
|
235 |
-
fn=
|
236 |
inputs=[input_mesh, example_image],
|
237 |
outputs=[model_output, exploded_parts_output],
|
238 |
-
cache_examples=
|
|
|
239 |
)
|
240 |
|
241 |
|
|
|
115 |
|
116 |
|
117 |
@spaces.GPU(duration=600)
|
118 |
+
def run_full(data_path: str, example_image=None, seed=42, num_inference_steps=25, guidance_scale=3.5, progress=gr.Progress(track_tqdm=True)):
|
119 |
|
120 |
batch_size = 30
|
121 |
parts_data = prepare_data(data_path)
|
|
|
148 |
return mesh_in
|
149 |
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
with gr.Blocks(title="HoloPart") as demo:
|
152 |
gr.Markdown(HEADER)
|
153 |
|
|
|
200 |
with gr.Row():
|
201 |
examples = gr.Examples(
|
202 |
examples=EXAMPLES,
|
203 |
+
fn=run_full,
|
204 |
inputs=[input_mesh, example_image],
|
205 |
outputs=[model_output, exploded_parts_output],
|
206 |
+
cache_examples=True,
|
207 |
+
cache_mode="lazy"
|
208 |
)
|
209 |
|
210 |
|