Spaces:
Runtime error
Runtime error
opt quick glb
Browse files
app.py
CHANGED
|
@@ -265,6 +265,36 @@ def split_image(image: Image.Image) -> List[Image.Image]:
|
|
| 265 |
images.append(Image.fromarray(image[:, s:e+1]))
|
| 266 |
return [preprocess_image(image) for image in images]
|
| 267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
| 270 |
gr.Markdown("""
|
|
@@ -310,6 +340,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
| 310 |
with gr.Row():
|
| 311 |
extract_glb_btn = gr.Button("Extract GLB", interactive=False)
|
| 312 |
extract_gs_btn = gr.Button("Extract Gaussian", interactive=False)
|
|
|
|
| 313 |
gr.Markdown("""
|
| 314 |
*NOTE: Gaussian file can be very large (~50MB), it will take a while to display and download.*
|
| 315 |
""")
|
|
@@ -321,11 +352,6 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
| 321 |
with gr.Row():
|
| 322 |
download_glb = gr.DownloadButton(label="Download GLB", interactive=False)
|
| 323 |
download_gs = gr.DownloadButton(label="Download Gaussian", interactive=False)
|
| 324 |
-
|
| 325 |
-
with gr.Accordion("Quick GLB from Image", open=False):
|
| 326 |
-
generate_glb_btn = gr.Button("Upload and Generate GLB Automatically")
|
| 327 |
-
quick_video = gr.Video(label="Quick 3D Preview", autoplay=True, loop=True)
|
| 328 |
-
quick_glb_download = gr.DownloadButton(label="Download GLB", interactive=False)
|
| 329 |
|
| 330 |
is_multiimage = gr.State(False)
|
| 331 |
output_buf = gr.State()
|
|
@@ -424,23 +450,26 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
| 424 |
|
| 425 |
generate_glb_btn.click(
|
| 426 |
lambda: get_seed(True, 0),
|
| 427 |
-
outputs=[
|
| 428 |
).then(
|
| 429 |
image_to_3d,
|
| 430 |
inputs=[
|
| 431 |
image_prompt,
|
| 432 |
gr.State([]),
|
| 433 |
gr.State(False),
|
| 434 |
-
|
| 435 |
gr.State(7.5), gr.State(12),
|
| 436 |
gr.State(3.0), gr.State(12),
|
| 437 |
gr.State("stochastic")
|
| 438 |
],
|
| 439 |
-
outputs=[output_buf,
|
| 440 |
).then(
|
| 441 |
extract_glb,
|
| 442 |
-
inputs=[output_buf,
|
| 443 |
-
outputs=[model_output,
|
|
|
|
|
|
|
|
|
|
| 444 |
)
|
| 445 |
|
| 446 |
|
|
|
|
| 265 |
images.append(Image.fromarray(image[:, s:e+1]))
|
| 266 |
return [preprocess_image(image) for image in images]
|
| 267 |
|
| 268 |
+
def quick_generate_glb(
|
| 269 |
+
image: Image.Image,
|
| 270 |
+
multiimages: List[Tuple[Image.Image, str]],
|
| 271 |
+
is_multiimage: bool,
|
| 272 |
+
seed: int,
|
| 273 |
+
ss_guidance_strength: float,
|
| 274 |
+
ss_sampling_steps: int,
|
| 275 |
+
slat_guidance_strength: float,
|
| 276 |
+
slat_sampling_steps: int,
|
| 277 |
+
multiimage_algo: Literal["multidiffusion", "stochastic"],
|
| 278 |
+
mesh_simplify: float,
|
| 279 |
+
texture_size: int,
|
| 280 |
+
req: gr.Request,
|
| 281 |
+
) -> Tuple[str, str]:
|
| 282 |
+
seed = get_seed(True, 0)
|
| 283 |
+
state, _ = image_to_3d(
|
| 284 |
+
image=image,
|
| 285 |
+
multiimages=[],
|
| 286 |
+
is_multiimage=False,
|
| 287 |
+
seed=seed,
|
| 288 |
+
ss_guidance_strength=7.5,
|
| 289 |
+
ss_sampling_steps=12,
|
| 290 |
+
slat_guidance_strength=3.0,
|
| 291 |
+
slat_sampling_steps=12,
|
| 292 |
+
multiimage_algo="stochastic",
|
| 293 |
+
req=None
|
| 294 |
+
)
|
| 295 |
+
return extract_glb(state, mesh_simplify=0.95, texture_size=1024, req=None)
|
| 296 |
+
|
| 297 |
+
|
| 298 |
|
| 299 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
| 300 |
gr.Markdown("""
|
|
|
|
| 340 |
with gr.Row():
|
| 341 |
extract_glb_btn = gr.Button("Extract GLB", interactive=False)
|
| 342 |
extract_gs_btn = gr.Button("Extract Gaussian", interactive=False)
|
| 343 |
+
generate_glb_btn = gr.Button("Quick Generate GLB")
|
| 344 |
gr.Markdown("""
|
| 345 |
*NOTE: Gaussian file can be very large (~50MB), it will take a while to display and download.*
|
| 346 |
""")
|
|
|
|
| 352 |
with gr.Row():
|
| 353 |
download_glb = gr.DownloadButton(label="Download GLB", interactive=False)
|
| 354 |
download_gs = gr.DownloadButton(label="Download Gaussian", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
|
| 356 |
is_multiimage = gr.State(False)
|
| 357 |
output_buf = gr.State()
|
|
|
|
| 450 |
|
| 451 |
generate_glb_btn.click(
|
| 452 |
lambda: get_seed(True, 0),
|
| 453 |
+
outputs=[]
|
| 454 |
).then(
|
| 455 |
image_to_3d,
|
| 456 |
inputs=[
|
| 457 |
image_prompt,
|
| 458 |
gr.State([]),
|
| 459 |
gr.State(False),
|
| 460 |
+
gr.State(0),
|
| 461 |
gr.State(7.5), gr.State(12),
|
| 462 |
gr.State(3.0), gr.State(12),
|
| 463 |
gr.State("stochastic")
|
| 464 |
],
|
| 465 |
+
outputs=[output_buf, video_output],
|
| 466 |
).then(
|
| 467 |
extract_glb,
|
| 468 |
+
inputs=[output_buf, gr.State(0.95), gr.State(1024)],
|
| 469 |
+
outputs=[model_output, glb_download]
|
| 470 |
+
).then(
|
| 471 |
+
lambda: gr.Button(interactive=True),
|
| 472 |
+
outputs=[glb_download]
|
| 473 |
)
|
| 474 |
|
| 475 |
|