zcmcxm commited on
Commit
a63d13c
1 Parent(s): 5f62c46

add basic setup

Browse files
app.py CHANGED
@@ -1,7 +1,113 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import argparse
3
+ import os, sys
4
+ import torch
5
 
6
+ # def greet(name):
7
+ # return "Hello " + name + "!!"
8
 
9
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
10
+ # iface.launch()
11
+
12
+ def parse_args() -> argparse.Namespace:
13
+ parser = argparse.ArgumentParser()
14
+ parser.add_argument('--device', type=str, default='cpu')
15
+ parser.add_argument('--theme', type=str)
16
+ parser.add_argument('--live', action='store_true')
17
+ parser.add_argument('--share', action='store_true')
18
+ parser.add_argument('--port', type=int)
19
+ parser.add_argument('--disable-queue',
20
+ dest='enable_queue',
21
+ action='store_false')
22
+ parser.add_argument('--allow-flagging', type=str, default='never')
23
+ parser.add_argument('--allow-screenshot', action='store_true')
24
+ return parser.parse_args()
25
+
26
+ _TITLE = '''DreamGaussian: Generative Gaussian Splatting for Efficient 3D Content Creation'''
27
+
28
+
29
+ _DESCRIPTION = '''
30
+ <div>
31
+ <a style="display:inline-block" href="https://dreamgaussian.github.io"></a>
32
+ <a style="display:inline-block; margin-left: .5em" href="https://arxiv.org/abs/2309.16653"><img src="https://img.shields.io/badge/2306.16928-f9f7f7?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAABMCAYAAADJPi9EAAAABHNCSVQIC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HtEt+XedsBOQtU9XMrRgjg4KTnc5nr+dmqadit/4C4uLm8DuA9koJTj1TL7fI5nDL+qqoo/FLGAzL7dYT17PzvAcQONYSUQRxW/QMrHZVIyik0ZuQA2mzp+Ji8BW4YM3Mbzm9inaHkJCGfrUZZjujiYailfFwA8DHIy3acwUj4v9vUVa+SmgNsl5fuyDTKovW9/IAmfLV0Pi2UncA515kjYdrwC9i9rpuHiq3JwtAAAAABJRU5ErkJggg=="></a>
33
+ <a style="display:inline-block; margin-left: .5em" href='https://github.com/dreamgaussian/dreamgaussian'><img src='https://img.shields.io/github/stars/dreamgaussian/dreamgaussian?style=social'/></a>
34
+ </div>
35
+ We present DreamGausssion, a 3D content generation framework that significantly improves the efficiency of 3D content creation.
36
+ '''
37
+ _USER_GUIDE = "Please upload an image in the block above (or choose an example above) and click **Run Generation**."
38
+
39
+ # trigger Image-to-3D model
40
+ def inference_img(img):
41
+ pass
42
+
43
+ # trigger Text-to-3D model
44
+ def inference_txt(txt):
45
+ pass
46
+
47
+ def run_demo():
48
+ args = parse_args()
49
+ args.device = 'cuda' if torch.cuda.is_available() else 'cpu'
50
+ print('*** Now using %s.'%(args.device))
51
+
52
+ with open('README.md', 'r') as f:
53
+ article = f.read()
54
+
55
+ # NOTE: Examples must match inputs
56
+ example_folder = os.path.join(os.path.dirname(__file__), 'demo_examples')
57
+ example_fns = os.listdir(example_folder)
58
+ example_fns.sort()
59
+ examples_full = [os.path.join(example_folder, x) for x in example_fns if x.endswith('.png')]
60
+
61
+ # Compose demo layout & data flow
62
+ with gr.Blocks(title=_TITLE, css="style.css") as demo:
63
+ with gr.Row():
64
+ with gr.Column(scale=1):
65
+ gr.Markdown('# ' + _TITLE)
66
+ with gr.Column(scale=0):
67
+ gr.DuplicateButton(value='Duplicate Space for private use',
68
+ elem_id='duplicate-button')
69
+ gr.Markdown(_DESCRIPTION)
70
+
71
+ # Image-to-3D
72
+ with gr.Row(variant='panel'):
73
+ with gr.Column(scale=6):
74
+ image_block = gr.Image(type='pil', image_mode='RGBA', height=290, label='Input image', tool=None)
75
+
76
+ gr.Examples(
77
+ examples=examples_full, # NOTE: elements must match inputs list!
78
+ inputs=[image_block],
79
+ outputs=[image_block],
80
+ cache_examples=False,
81
+ label='Examples (click one of the images below to start)',
82
+ examples_per_page=40
83
+ )
84
+ img_run_btn = gr.Button('Run Generation', variant='primary', interactive=False)
85
+ img_guide_text = gr.Markdown(_USER_GUIDE, visible=True)
86
+
87
+ with gr.Column(scale=4):
88
+ img_mesh_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="Textured Mesh", elem_id="img-model-3d-out")
89
+
90
+ # Text-to-3D
91
+ with gr.Row(variant='panel'):
92
+ with gr.Column(scale=6):
93
+ text_block = gr.Textbox(label="Input text")
94
+
95
+ txt_run_btn = gr.Button('Run Generation', variant='primary', interactive=False)
96
+ txt_guide_text = gr.Markdown(_USER_GUIDE, visible=True)
97
+
98
+ with gr.Column(scale=4):
99
+ txt_mesh_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="Textured Mesh", elem_id="txt-model-3d-out")
100
+
101
+ gr.Markdown(article)
102
+ gr.HTML("""
103
+ <div class="footer">
104
+ <p>
105
+ This is a test demo
106
+ </p>
107
+ </div>
108
+ """)
109
+
110
+ demo.queue().launch(share=False, max_threads=80) # auth=("admin", os.environ['PASSWD'])
111
+
112
+ if __name__ == '__main__':
113
+ run_demo()
demo_examples/catstatue_rgba.png ADDED
demo_examples/csm_luigi_rgba.png ADDED
style.css ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #model-3d-out {
2
+ height: 400px;
3
+ }
4
+
5
+ #plot-out {
6
+ height: 450px;
7
+ }
8
+
9
+ #duplicate-button {
10
+ margin-left: auto;
11
+ color: #fff;
12
+ background: coral;
13
+ }
14
+
15
+ .footer {
16
+ margin-bottom: 45px;
17
+ margin-top: 10px;
18
+ text-align: center;
19
+ border-bottom: 1px solid #e5e5e5;
20
+ }
21
+ .footer>p {
22
+ font-size: .8rem;
23
+ display: inline-block;
24
+ padding: 0 10px;
25
+ transform: translateY(15px);
26
+ background: white;
27
+ }
28
+ .dark .footer {
29
+ border-color: #303030;
30
+ }
31
+ .dark .footer>p {
32
+ background: #0b0f19;
33
+ }