cavargas10 commited on
Commit
49c6f1e
·
verified ·
1 Parent(s): f7b7abd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -29
app.py CHANGED
@@ -136,44 +136,72 @@ def split_image(image: Image.Image) -> List[Image.Image]:
136
  with gr.Blocks(delete_cache=(600, 600)) as demo:
137
  gr.Markdown("""
138
  ## Image to 3D Asset with [TRELLIS](https://trellis3d.github.io/)
139
- * Upload an image and click "Generate" to create a 3D asset. If the image has alpha channel, it be used as the mask. Otherwise, we use `rembg` to remove the background.
140
- * If you find the generated 3D asset satisfactory, click "Extract GLB" to extract the GLB file and download it.
141
-
142
  ✨New: Experimental multi-image support.
143
  """)
144
 
145
- with gr.Row():
146
- with gr.Column():
147
- with gr.Tabs() as input_tabs:
148
- with gr.Tab(label="Single Image", id=0) as single_image_input_tab:
149
- image_prompt = gr.Image(label="Image Prompt", format="png", image_mode="RGBA", type="pil", height=300)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
- with gr.Accordion(label="Generation Settings", open=False):
152
- seed = gr.Slider(0, MAX_SEED, label="Seed", value=0, step=1)
153
- randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
154
- gr.Markdown("Stage 1: Sparse Structure Generation")
155
- with gr.Row():
156
- ss_guidance_strength = gr.Slider(0.0, 10.0, label="Guidance Strength", value=7.5, step=0.1)
157
- ss_sampling_steps = gr.Slider(1, 50, label="Sampling Steps", value=12, step=1)
158
- gr.Markdown("Stage 2: Structured Latent Generation")
159
- with gr.Row():
160
- slat_guidance_strength = gr.Slider(0.0, 10.0, label="Guidance Strength", value=3.0, step=0.1)
161
- slat_sampling_steps = gr.Slider(1, 50, label="Sampling Steps", value=12, step=1)
162
-
163
- generate_btn = gr.Button("Generate")
164
 
165
- with gr.Accordion(label="GLB Extraction Settings", open=False):
166
- mesh_simplify = gr.Slider(0.9, 0.98, label="Simplify", value=0.95, step=0.01)
167
- texture_size = gr.Slider(512, 2048, label="Texture Size", value=1024, step=512)
168
 
169
- extract_glb_btn = gr.Button("Extract GLB", interactive=False)
 
 
 
 
170
 
171
- with gr.Column():
172
- video_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
173
- model_output = LitModel3D(label="Extracted GLB", exposure=10.0, height=300)
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
  with gr.Row():
176
- download_glb = gr.DownloadButton(label="Download GLB", interactive=False)
 
 
 
 
 
177
 
178
  output_buf = gr.State()
179
 
 
136
  with gr.Blocks(delete_cache=(600, 600)) as demo:
137
  gr.Markdown("""
138
  ## Image to 3D Asset with [TRELLIS](https://trellis3d.github.io/)
139
+ * Upload an image and click "Generate" to create a 3D asset. If the image has alpha channel, it will be used as the mask. Otherwise, we use `rembg` to remove the background.
140
+ * If satisfied, click "Extract GLB" to download the 3D model.
 
141
  ✨New: Experimental multi-image support.
142
  """)
143
 
144
+ with gr.Row(equal_height=False):
145
+ # Left column (Controls)
146
+ with gr.Column(scale=2, min_width=400):
147
+ with gr.Tabs():
148
+ with gr.Tab(label="Input Image"):
149
+ image_prompt = gr.Image(
150
+ label="Image Prompt",
151
+ format="png",
152
+ image_mode="RGBA",
153
+ type="pil",
154
+ height=300,
155
+ show_label=False
156
+ )
157
+
158
+ with gr.Accordion(".Generation Settings", open=False):
159
+ with gr.Column(variant="panel"):
160
+ seed = gr.Slider(0, MAX_SEED, label="Seed", value=0, step=1)
161
+ randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
162
+
163
+ with gr.Group():
164
+ gr.Markdown("#### Stage 1: Structure")
165
+ ss_guidance_strength = gr.Slider(0.0, 10.0, label="Guidance", value=7.5, step=0.1)
166
+ ss_sampling_steps = gr.Slider(1, 50, label="Steps", value=12, step=1)
167
 
168
+ with gr.Group():
169
+ gr.Markdown("#### Stage 2: Detail")
170
+ slat_guidance_strength = gr.Slider(0.0, 10.0, label="Guidance", value=3.0, step=0.1)
171
+ slat_sampling_steps = gr.Slider(1, 50, label="Steps", value=12, step=1)
 
 
 
 
 
 
 
 
 
172
 
173
+ generate_btn = gr.Button("Generate 3D Asset", variant="primary", size="lg")
 
 
174
 
175
+ with gr.Accordion("GLB Export Settings", open=False):
176
+ with gr.Column(variant="panel"):
177
+ mesh_simplify = gr.Slider(0.9, 0.98, label="Simplify Mesh", value=0.95, step=0.01)
178
+ texture_size = gr.Slider(512, 2048, label="Texture Size", value=1024, step=512)
179
+ extract_glb_btn = gr.Button("Export GLB", interactive=False, size="lg")
180
 
181
+ # Right column (Outputs)
182
+ with gr.Column(scale=3, min_width=600):
183
+ with gr.Group():
184
+ video_output = gr.Video(
185
+ label="3D Preview",
186
+ autoplay=True,
187
+ loop=True,
188
+ height=300,
189
+ show_label=False
190
+ )
191
+ model_output = LitModel3D(
192
+ label="3D Model Viewer",
193
+ exposure=10.0,
194
+ height=400,
195
+ clear_color=[1.0, 1.0, 1.0, 1.0]
196
+ )
197
 
198
  with gr.Row():
199
+ download_glb = gr.DownloadButton(
200
+ label="Download GLB File",
201
+ interactive=False,
202
+ variant="secondary",
203
+ size="lg"
204
+ )
205
 
206
  output_buf = gr.State()
207