YUGOROU commited on
Commit
4bdbcf1
·
verified ·
1 Parent(s): d21eece

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +52 -55
app.py CHANGED
@@ -449,59 +449,56 @@ def gen3dmesh(img_input0, img_input1, img_input2, img_input3, back_proj, smooth_
449
  return run_inference3d(img_input0, img_input1, img_input2, img_input3, back_proj, smooth_iter)
450
 
451
 
452
- @torch.no_grad()
453
- def main():
454
- with gr.Blocks() as demo:
455
- gr.Markdown("# [SIGGRAPH'24] CharacterGen: Efficient 3D Character Generation from Single Images with Multi-View Pose Calibration")
456
- with gr.Row():
457
- with gr.Column(variant="panel"):
458
- img_input = gr.Image(type="pil", label="Upload Image(without background)", image_mode="RGBA", width=768, height=512)
459
- gr.Examples(
460
- label="Example Images",
461
- examples=glob.glob("./2D_Stage/material/examples/*.png"),
462
- inputs=[img_input]
463
- )
464
- with gr.Row():
465
- width_input = gr.Number(label="Width", value=512)
466
- height_input = gr.Number(label="Height", value=768)
467
- seed_input = gr.Number(label="Seed", value=2333)
468
- remove_bg = gr.Checkbox(label="Remove Background (with algorithm)", value=True)
469
- with gr.Column(variant="panel"):
470
- timestep = gr.Slider(minimum=10, maximum=70, step=1, value=40, label="Timesteps")
471
- button1 = gr.Button(value="Generate 4 Views")
472
- with gr.Row():
473
- img_input0 = gr.Image(type="pil", label="Back Image", image_mode="RGBA", width=256, height=384)
474
- img_input1 = gr.Image(type="pil", label="Front Image", image_mode="RGBA", width=256, height=384)
475
- with gr.Row():
476
- img_input2 = gr.Image(type="pil", label="Right Image", image_mode="RGBA", width=256, height=384)
477
- img_input3 = gr.Image(type="pil", label="Left Image", image_mode="RGBA", width=256, height=384)
478
- with gr.Column(variant="panel"):
479
- smooth_iter = gr.Slider(minimum=0, maximum=10, step=1, value=5, label="Laplacian Smoothing Iterations")
480
- with gr.Row():
481
- back_proj = gr.Checkbox(label="Back Projection")
482
- button2 = gr.Button(value="Generate 3D Mesh")
483
- output_dir = gr.Textbox(label="Output Directory")
484
- with gr.Row():
485
- with gr.Tab("GLB"):
486
- output_model_glb = gr.Model3D( label="Output Model (GLB Format)", height=512)
487
- gr.Markdown("Note: The model shown here has a darker appearance. Download to get correct results.")
488
- with gr.Tab("OBJ"):
489
- output_model_obj = gr.Model3D( label="Output Model (OBJ Format)")
490
- gr.Markdown("Note: The model shown here's texture is mapped to vertex. Download to get correct results.")
491
- button1.click(
492
- fn=gen4views,
493
- inputs=[img_input, width_input, height_input, seed_input, timestep, remove_bg],
494
- outputs=[img_input2, img_input0, img_input3, img_input1],
495
- api_name="generate_views"
496
- )
497
- button2.click(
498
- gen3dmesh,
499
- inputs=[img_input0, img_input1, img_input2, img_input3, back_proj, smooth_iter],
500
- outputs=[output_dir, output_model_obj, output_model_glb],
501
- api_name="generate_3d_mesh"
502
- )
503
- demo.queue()
504
- demo.launch()
505
 
506
- if __name__ == "__main__":
507
- main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  return run_inference3d(img_input0, img_input1, img_input2, img_input3, back_proj, smooth_iter)
450
 
451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
452
 
453
+ with gr.Blocks() as demo:
454
+ gr.Markdown("# [SIGGRAPH'24] CharacterGen: Efficient 3D Character Generation from Single Images with Multi-View Pose Calibration")
455
+ with gr.Row():
456
+ with gr.Column(variant="panel"):
457
+ img_input = gr.Image(type="pil", label="Upload Image(without background)", image_mode="RGBA", width=768, height=512)
458
+ gr.Examples(
459
+ label="Example Images",
460
+ examples=glob.glob("./2D_Stage/material/examples/*.png"),
461
+ inputs=[img_input]
462
+ )
463
+ with gr.Row():
464
+ width_input = gr.Number(label="Width", value=512)
465
+ height_input = gr.Number(label="Height", value=768)
466
+ seed_input = gr.Number(label="Seed", value=2333)
467
+ remove_bg = gr.Checkbox(label="Remove Background (with algorithm)", value=True)
468
+ with gr.Column(variant="panel"):
469
+ timestep = gr.Slider(minimum=10, maximum=70, step=1, value=40, label="Timesteps")
470
+ button1 = gr.Button(value="Generate 4 Views")
471
+ with gr.Row():
472
+ img_input0 = gr.Image(type="pil", label="Back Image", image_mode="RGBA", width=256, height=384)
473
+ img_input1 = gr.Image(type="pil", label="Front Image", image_mode="RGBA", width=256, height=384)
474
+ with gr.Row():
475
+ img_input2 = gr.Image(type="pil", label="Right Image", image_mode="RGBA", width=256, height=384)
476
+ img_input3 = gr.Image(type="pil", label="Left Image", image_mode="RGBA", width=256, height=384)
477
+ with gr.Column(variant="panel"):
478
+ smooth_iter = gr.Slider(minimum=0, maximum=10, step=1, value=5, label="Laplacian Smoothing Iterations")
479
+ with gr.Row():
480
+ back_proj = gr.Checkbox(label="Back Projection")
481
+ button2 = gr.Button(value="Generate 3D Mesh")
482
+ output_dir = gr.Textbox(label="Output Directory")
483
+ with gr.Row():
484
+ with gr.Tab("GLB"):
485
+ output_model_glb = gr.Model3D( label="Output Model (GLB Format)", height=512)
486
+ gr.Markdown("Note: The model shown here has a darker appearance. Download to get correct results.")
487
+ with gr.Tab("OBJ"):
488
+ output_model_obj = gr.Model3D( label="Output Model (OBJ Format)")
489
+ gr.Markdown("Note: The model shown here's texture is mapped to vertex. Download to get correct results.")
490
+ button1.click(
491
+ fn=gen4views,
492
+ inputs=[img_input, width_input, height_input, seed_input, timestep, remove_bg],
493
+ outputs=[img_input2, img_input0, img_input3, img_input1],
494
+ api_name="generate_views"
495
+ )
496
+ button2.click(
497
+ gen3dmesh,
498
+ inputs=[img_input0, img_input1, img_input2, img_input3, back_proj, smooth_iter],
499
+ outputs=[output_dir, output_model_obj, output_model_glb],
500
+ api_name="generate_3d_mesh"
501
+ )
502
+
503
+ demo.queue()
504
+ demo.launch()