Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -102,7 +102,7 @@ def first_file_from_dir(directory, ext):
|
|
102 |
@torch.no_grad()
|
103 |
def run_triposg(image_path: str,
|
104 |
num_parts: int = 1,
|
105 |
-
seed: int =
|
106 |
num_tokens: int = 1024,
|
107 |
num_inference_steps: int = 50,
|
108 |
guidance_scale: float = 7.0,
|
@@ -170,53 +170,60 @@ def run_triposg(image_path: str,
|
|
170 |
|
171 |
# Gradio Interface
|
172 |
def build_demo():
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
with gr.
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
if __name__ == "__main__":
|
222 |
demo = build_demo()
|
|
|
102 |
@torch.no_grad()
|
103 |
def run_triposg(image_path: str,
|
104 |
num_parts: int = 1,
|
105 |
+
seed: int = 0,
|
106 |
num_tokens: int = 1024,
|
107 |
num_inference_steps: int = 50,
|
108 |
guidance_scale: float = 7.0,
|
|
|
170 |
|
171 |
# Gradio Interface
|
172 |
def build_demo():
|
173 |
+
css = """
|
174 |
+
#col-container {
|
175 |
+
margin: 0 auto;
|
176 |
+
max-width: 1024px;
|
177 |
+
}
|
178 |
+
"""
|
179 |
+
theme = gr.themes.Ocean()
|
180 |
+
|
181 |
+
with gr.Blocks(css=css, theme=theme) as demo:
|
182 |
+
|
183 |
+
with gr.Column(elem_id="col-container"):
|
184 |
+
|
185 |
+
gr.Markdown(
|
186 |
+
""" # PartCrafter – Structured 3D Mesh Generation via Compositional Latent Diffusion Transformers
|
187 |
+
|
188 |
+
• Source: [Github](https://github.com/wgsxm/PartCrafter)
|
189 |
+
• HF Space by : [@alexandernasa](https://twitter.com/alexandernasa/) """
|
190 |
+
)
|
191 |
+
with gr.Row():
|
192 |
+
with gr.Column(scale=1):
|
193 |
+
input_image = gr.Image(type="filepath", label="Input Image")
|
194 |
+
num_parts = gr.Slider(1, MAX_NUM_PARTS, value=4, step=1, label="Number of Parts")
|
195 |
+
run_button = gr.Button("Generate 3D Parts", variant="primary")
|
196 |
+
|
197 |
+
with gr.Accordion("Advanced Settings", open=False):
|
198 |
+
seed = gr.Number(value=0, label="Random Seed", precision=0)
|
199 |
+
num_tokens = gr.Slider(256, 2048, value=1024, step=64, label="Num Tokens")
|
200 |
+
num_steps = gr.Slider(1, 100, value=50, step=1, label="Inference Steps")
|
201 |
+
guidance = gr.Slider(1.0, 20.0, value=7.0, step=0.1, label="Guidance Scale")
|
202 |
+
flash_decoder = gr.Checkbox(value=False, label="Use Flash Decoder")
|
203 |
+
remove_bg = gr.Checkbox(value=False, label="Remove Background (RMBG)")
|
204 |
+
|
205 |
+
with gr.Column(scale=1):
|
206 |
+
output_model = gr.Model3D(label="Merged 3D Object")
|
207 |
+
output_dir = gr.Textbox(label="Export Directory")
|
208 |
+
examples = gr.Examples(
|
209 |
+
examples=[
|
210 |
+
[
|
211 |
+
"assets/images/np4_7bd5d25aa77b4fb18e780d7a4c97d342.png",
|
212 |
+
4,
|
213 |
+
],
|
214 |
+
|
215 |
+
],
|
216 |
+
inputs=[input_image, num_parts],
|
217 |
+
outputs=[output_model, output_dir],
|
218 |
+
fn=run_triposg,
|
219 |
+
cache_examples=True,
|
220 |
+
)
|
221 |
+
|
222 |
+
run_button.click(fn=run_triposg,
|
223 |
+
inputs=[input_image, num_parts, seed, num_tokens, num_steps,
|
224 |
+
guidance, flash_decoder, remove_bg],
|
225 |
+
outputs=[output_model, output_dir])
|
226 |
+
return demo
|
227 |
|
228 |
if __name__ == "__main__":
|
229 |
demo = build_demo()
|