import gradio as gr import argparse import os, sys import torch # def greet(name): # return "Hello " + name + "!!" # iface = gr.Interface(fn=greet, inputs="text", outputs="text") # iface.launch() def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument('--device', type=str, default='cpu') parser.add_argument('--theme', type=str) parser.add_argument('--live', action='store_true') parser.add_argument('--share', action='store_true') parser.add_argument('--port', type=int) parser.add_argument('--disable-queue', dest='enable_queue', action='store_false') parser.add_argument('--allow-flagging', type=str, default='never') parser.add_argument('--allow-screenshot', action='store_true') return parser.parse_args() _TITLE = '''DreamGaussian: Generative Gaussian Splatting for Efficient 3D Content Creation''' _DESCRIPTION = '''
We present DreamGausssion, a 3D content generation framework that significantly improves the efficiency of 3D content creation. ''' _USER_GUIDE = "Please upload an image in the block above (or choose an example above) and click **Run Generation**." # trigger Image-to-3D model def inference_img(img): pass # trigger Text-to-3D model def inference_txt(txt): pass def run_demo(): args = parse_args() args.device = 'cuda' if torch.cuda.is_available() else 'cpu' print('*** Now using %s.'%(args.device)) with open('README.md', 'r') as f: article = f.read() # NOTE: Examples must match inputs example_folder = os.path.join(os.path.dirname(__file__), 'demo_examples') example_fns = os.listdir(example_folder) example_fns.sort() examples_full = [os.path.join(example_folder, x) for x in example_fns if x.endswith('.png')] # Compose demo layout & data flow with gr.Blocks(title=_TITLE, css="style.css") as demo: with gr.Row(): with gr.Column(scale=1): gr.Markdown('# ' + _TITLE) with gr.Column(scale=0): gr.DuplicateButton(value='Duplicate Space for private use', elem_id='duplicate-button') gr.Markdown(_DESCRIPTION) # Image-to-3D with gr.Row(variant='panel'): with gr.Column(scale=6): image_block = gr.Image(type='pil', image_mode='RGBA', height=290, label='Input image', tool=None) gr.Examples( examples=examples_full, # NOTE: elements must match inputs list! inputs=[image_block], outputs=[image_block], cache_examples=False, label='Examples (click one of the images below to start)', examples_per_page=40 ) img_run_btn = gr.Button('Run Generation', variant='primary', interactive=False) img_guide_text = gr.Markdown(_USER_GUIDE, visible=True) with gr.Column(scale=4): img_mesh_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="Textured Mesh", elem_id="img-model-3d-out") # Text-to-3D with gr.Row(variant='panel'): with gr.Column(scale=6): text_block = gr.Textbox(label="Input text") txt_run_btn = gr.Button('Run Generation', variant='primary', interactive=False) txt_guide_text = gr.Markdown(_USER_GUIDE, visible=True) with gr.Column(scale=4): txt_mesh_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="Textured Mesh", elem_id="txt-model-3d-out") gr.Markdown(article) gr.HTML(""" """) demo.queue().launch(share=False, max_threads=80) # auth=("admin", os.environ['PASSWD']) if __name__ == '__main__': run_demo()