JiantaoLin
commited on
Commit
ยท
d94abd9
1
Parent(s):
c0dbb78
new
Browse files
app.py
CHANGED
|
@@ -96,7 +96,7 @@ from pipeline.kiss3d_wrapper import init_wrapper_from_config, run_text_to_3d, ru
|
|
| 96 |
# Add logo file path and hyperlinks
|
| 97 |
LOGO_PATH = "app_assets/logo_temp_.png" # Update this to the actual path of your logo
|
| 98 |
ARXIV_LINK = "https://arxiv.org/abs/example"
|
| 99 |
-
GITHUB_LINK = "https://github.com/
|
| 100 |
|
| 101 |
|
| 102 |
k3d_wrapper = init_wrapper_from_config('./pipeline/pipeline_config/default.yaml')
|
|
@@ -251,15 +251,17 @@ def bundle_image_to_mesh(
|
|
| 251 |
else:
|
| 252 |
return recon_mesh_path, mesh_cache
|
| 253 |
|
| 254 |
-
_HEADER_=f"""
|
| 255 |
-
<img src="{LOGO_PATH}">
|
| 256 |
-
|
| 257 |
-
|
|
|
|
| 258 |
|
| 259 |
-
<p>**Kiss3DGen** is xxxxxxxxx</p>
|
| 260 |
|
| 261 |
-
|
| 262 |
-
|
|
|
|
|
|
|
| 263 |
|
| 264 |
_CITE_ = r"""
|
| 265 |
<h2>If Kiss3DGen is helpful, please help to โญ the <a href='{""" + GITHUB_LINK + r"""}' target='_blank'>Github Repo</a>. Thanks!</h2>
|
|
@@ -392,7 +394,9 @@ with gr.Blocks(css="""
|
|
| 392 |
# gr.Markdown(f"[]({GITHUB_LINK})")
|
| 393 |
|
| 394 |
# Tabs Section
|
| 395 |
-
with gr.Tabs(selected='tab_text_to_3d', elem_id="content-container") as main_tabs:
|
|
|
|
|
|
|
| 396 |
with gr.TabItem('Text-to-3D', id='tab_text_to_3d'):
|
| 397 |
with gr.Row():
|
| 398 |
with gr.Column(scale=1):
|
|
@@ -410,9 +414,9 @@ with gr.Blocks(css="""
|
|
| 410 |
inputs=[prompt], # ๅฐ้ไธญ็็คบไพๅกซๅ
ฅ prompt ๆๆฌๆก
|
| 411 |
label="Example Prompts"
|
| 412 |
)
|
| 413 |
-
btn_text2detailed = gr.Button("Refine to detailed prompt")
|
| 414 |
detailed_prompt = gr.Textbox(value="", label="Detailed Prompt", placeholder="detailed prompt will be generated here base on your input prompt. You can also edit this prompt", lines=4, interactive=True)
|
| 415 |
-
btn_text2img = gr.Button("Generate Images")
|
| 416 |
|
| 417 |
with gr.Column(scale=1):
|
| 418 |
output_image1 = gr.Image(label="Generated image", interactive=False)
|
|
@@ -423,12 +427,12 @@ with gr.Blocks(css="""
|
|
| 423 |
# reconstruction_stage1_steps = gr.Number(value=10, label="reconstruction_stage1_steps")
|
| 424 |
# reconstruction_stage2_steps = gr.Number(value=50, label="reconstruction_stage2_steps")
|
| 425 |
|
| 426 |
-
btn_gen_mesh = gr.Button("Generate Mesh")
|
| 427 |
output_video1 = gr.Video(label="Render Video", interactive=False, loop=True, autoplay=True)
|
| 428 |
# btn_download1 = gr.Button("Download Mesh")
|
| 429 |
|
| 430 |
|
| 431 |
-
download_1 = gr.DownloadButton(label="Download mesh", interactive=False)
|
| 432 |
|
| 433 |
# file_output1 = gr.File()
|
| 434 |
|
|
@@ -476,54 +480,13 @@ with gr.Blocks(css="""
|
|
| 476 |
|
| 477 |
# Button Click Events
|
| 478 |
# Text2
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
# Step 1: ็นๅป "Refine to detailed prompt" ๆ้ฎๆถ
|
| 489 |
-
def refine_to_detailed(prompt, seed):
|
| 490 |
-
global generated_detailed_prompt
|
| 491 |
-
detailed_prompt_value = text_to_detailed(prompt, seed)
|
| 492 |
-
generated_detailed_prompt = True
|
| 493 |
-
return detailed_prompt_value
|
| 494 |
-
|
| 495 |
-
# Step 2: ็นๅป "Generate Image" ๆ้ฎๆถ
|
| 496 |
-
def generate_image(prompt, seed, detailed_prompt_value):
|
| 497 |
-
global generated_image, generated_detailed_prompt
|
| 498 |
-
# ๅฆๆๆฒกๆ็ๆ่ฟ่ฏฆ็ปๆ่ฟฐ๏ผๅ
ๆง่ก refine-to-detailed
|
| 499 |
-
if not generated_detailed_prompt:
|
| 500 |
-
detailed_prompt_value = text_to_detailed(prompt, seed)
|
| 501 |
-
generated_detailed_prompt = True
|
| 502 |
-
else:
|
| 503 |
-
detailed_prompt_value = f"Already refined: {prompt} (Seed: {seed})"
|
| 504 |
-
|
| 505 |
-
generated_image = True
|
| 506 |
-
return detailed_prompt_value, text_to_image(detailed_prompt_value, seed)
|
| 507 |
-
|
| 508 |
-
# Step 3: ็นๅป "Generate Mesh" ๆ้ฎๆถ
|
| 509 |
-
def generate_mesh(image):
|
| 510 |
-
global generated_detailed_prompt, generated_image
|
| 511 |
-
# ๅฆๆๆฒกๆ็ๆๅพๅ๏ผๅ
ๆง่ก็ๆๅพๅ
|
| 512 |
-
if not generated_image:
|
| 513 |
-
detailed_prompt_value = text_to_detailed(prompt, seed1)
|
| 514 |
-
image = text_to_image(detailed_prompt_value, seed1)
|
| 515 |
-
generated_image = True
|
| 516 |
-
generated_detailed_prompt, generated_image = False, False
|
| 517 |
-
# ็ๆ็ฝๆ ผ
|
| 518 |
-
return bundle_image_to_mesh(image)
|
| 519 |
-
# Button Click Events
|
| 520 |
-
btn_text2detailed.click(fn=refine_to_detailed, inputs=[prompt, seed1], outputs=detailed_prompt)
|
| 521 |
-
|
| 522 |
-
# Generate Image
|
| 523 |
-
btn_text2img.click(fn=generate_image, inputs=[prompt, seed1, detailed_prompt], outputs=[detailed_prompt, output_image1])
|
| 524 |
|
| 525 |
-
# Generate Mesh
|
| 526 |
-
btn_gen_mesh.click(fn=generate_mesh, inputs=[output_image1], outputs=[output_video1, download_1])
|
| 527 |
|
| 528 |
with gr.Row():
|
| 529 |
pass
|
|
|
|
| 96 |
# Add logo file path and hyperlinks
|
| 97 |
LOGO_PATH = "app_assets/logo_temp_.png" # Update this to the actual path of your logo
|
| 98 |
ARXIV_LINK = "https://arxiv.org/abs/example"
|
| 99 |
+
GITHUB_LINK = "https://github.com/EnVision-Research/Kiss3DGen"
|
| 100 |
|
| 101 |
|
| 102 |
k3d_wrapper = init_wrapper_from_config('./pipeline/pipeline_config/default.yaml')
|
|
|
|
| 251 |
else:
|
| 252 |
return recon_mesh_path, mesh_cache
|
| 253 |
|
| 254 |
+
# _HEADER_=f"""
|
| 255 |
+
# <img src="{LOGO_PATH}">
|
| 256 |
+
# <h2><b>Official ๐ค Gradio Demo</b></h2>
|
| 257 |
+
# <h2><b>Kiss3DGen: Repurposing Image Diffusion Models for 3D Asset Generation</b></h2>
|
| 258 |
+
# <h2>Try our demo:Please click the buttons in sequence. Feel free to redo some steps multiple times until you get a </h2>
|
| 259 |
|
|
|
|
| 260 |
|
| 261 |
+
|
| 262 |
+
# []({ARXIV_LINK}) []({GITHUB_LINK})
|
| 263 |
+
|
| 264 |
+
# """
|
| 265 |
|
| 266 |
_CITE_ = r"""
|
| 267 |
<h2>If Kiss3DGen is helpful, please help to โญ the <a href='{""" + GITHUB_LINK + r"""}' target='_blank'>Github Repo</a>. Thanks!</h2>
|
|
|
|
| 394 |
# gr.Markdown(f"[]({GITHUB_LINK})")
|
| 395 |
|
| 396 |
# Tabs Section
|
| 397 |
+
# with gr.Tabs(selected='tab_text_to_3d', elem_id="content-container") as main_tabs:
|
| 398 |
+
if True:
|
| 399 |
+
gr.Markdown("Explore our Text-to-3D demo! Click the buttons in order (1 to 4). Adjust the seed or input to refine each step until you're satisfied before moving to the next.")
|
| 400 |
with gr.TabItem('Text-to-3D', id='tab_text_to_3d'):
|
| 401 |
with gr.Row():
|
| 402 |
with gr.Column(scale=1):
|
|
|
|
| 414 |
inputs=[prompt], # ๅฐ้ไธญ็็คบไพๅกซๅ
ฅ prompt ๆๆฌๆก
|
| 415 |
label="Example Prompts"
|
| 416 |
)
|
| 417 |
+
btn_text2detailed = gr.Button("1. Refine to detailed prompt")
|
| 418 |
detailed_prompt = gr.Textbox(value="", label="Detailed Prompt", placeholder="detailed prompt will be generated here base on your input prompt. You can also edit this prompt", lines=4, interactive=True)
|
| 419 |
+
btn_text2img = gr.Button("2. Generate Images")
|
| 420 |
|
| 421 |
with gr.Column(scale=1):
|
| 422 |
output_image1 = gr.Image(label="Generated image", interactive=False)
|
|
|
|
| 427 |
# reconstruction_stage1_steps = gr.Number(value=10, label="reconstruction_stage1_steps")
|
| 428 |
# reconstruction_stage2_steps = gr.Number(value=50, label="reconstruction_stage2_steps")
|
| 429 |
|
| 430 |
+
btn_gen_mesh = gr.Button("3. Generate Mesh")
|
| 431 |
output_video1 = gr.Video(label="Render Video", interactive=False, loop=True, autoplay=True)
|
| 432 |
# btn_download1 = gr.Button("Download Mesh")
|
| 433 |
|
| 434 |
|
| 435 |
+
download_1 = gr.DownloadButton(label="4. Download mesh", interactive=False)
|
| 436 |
|
| 437 |
# file_output1 = gr.File()
|
| 438 |
|
|
|
|
| 480 |
|
| 481 |
# Button Click Events
|
| 482 |
# Text2
|
| 483 |
+
btn_text2detailed.click(fn=text_to_detailed, inputs=[prompt, seed1], outputs=detailed_prompt)
|
| 484 |
+
btn_text2img.click(fn=text_to_image, inputs=[detailed_prompt, seed1], outputs=output_image1)
|
| 485 |
+
btn_gen_mesh.click(fn=bundle_image_to_mesh, inputs=[output_image1,], outputs=[output_video1, download_1]).then(
|
| 486 |
+
lambda: gr.Button(interactive=True),
|
| 487 |
+
outputs=[download_1],
|
| 488 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
|
|
|
|
|
|
|
| 490 |
|
| 491 |
with gr.Row():
|
| 492 |
pass
|