FrozenBurning commited on
Commit
2c17c74
1 Parent(s): 49ab044

Update app.py

Browse files
Files changed (2) hide show
  1. app.py +12 -5
  2. assets/examples/bubble_mart_blue.png +0 -0
app.py CHANGED
@@ -50,8 +50,8 @@ amp = True
50
  precision_dtype = torch.float16
51
 
52
  rm = RayMarcher(
53
- config.image_height,
54
- config.image_width,
55
  **config.rm,
56
  ).to(device)
57
 
@@ -143,12 +143,16 @@ def process(input_cond, input_num_steps, input_seed=42, input_cfg=6.0):
143
 
144
  return output_rgb_video_path, output_prim_video_path, output_mat_video_path, gr.update(interactive=True)
145
 
146
- def export_mesh(remesh=False, decimate=100000, mc_resolution=256):
147
  # exporting GLB mesh
148
  output_glb_path = os.path.join(config.output_dir, GRADIO_GLB_PATH)
149
- config.inference.remesh = remesh
 
 
 
150
  config.inference.decimate = decimate
151
  config.inference.mc_resolution = mc_resolution
 
152
  denoise_param_path = os.path.join(config.output_dir, 'denoised.pt')
153
  primx_ckpt_weight = torch.load(denoise_param_path, map_location='cpu')['model_state_dict']
154
  model_primx.load_state_dict(primx_ckpt_weight)
@@ -195,6 +199,9 @@ with block:
195
  input_seed = gr.Slider(label="random seed", minimum=0, maximum=10000, step=1, value=42, info="Try different seed if the result is not satisfying as this is a generative model!")
196
  # gen button
197
  button_gen = gr.Button(value="Generate", interactive=False)
 
 
 
198
  export_glb_btn = gr.Button(value="Export GLB", interactive=False)
199
 
200
  with gr.Column(scale=1):
@@ -240,7 +247,7 @@ with block:
240
 
241
  input_image.change(background_remove_process, inputs=[input_image], outputs=[button_gen, current_fg_state, removal_previewer])
242
  button_gen.click(process, inputs=[current_fg_state, input_num_steps, input_seed, input_cfg], outputs=[output_rgb_video, output_prim_video, output_mat_video, export_glb_btn])
243
- export_glb_btn.click(export_mesh, inputs=[], outputs=[output_glb, hdr_row])
244
 
245
  gr.Examples(
246
  examples=[
 
50
  precision_dtype = torch.float16
51
 
52
  rm = RayMarcher(
53
+ 256,
54
+ 256,
55
  **config.rm,
56
  ).to(device)
57
 
 
143
 
144
  return output_rgb_video_path, output_prim_video_path, output_mat_video_path, gr.update(interactive=True)
145
 
146
+ def export_mesh(remesh="No", mc_resolution=256, decimate=100000):
147
  # exporting GLB mesh
148
  output_glb_path = os.path.join(config.output_dir, GRADIO_GLB_PATH)
149
+ if remesh == "No":
150
+ config.inference.remesh = False
151
+ elif remesh == "Yes":
152
+ config.inference.remesh = True
153
  config.inference.decimate = decimate
154
  config.inference.mc_resolution = mc_resolution
155
+ config.inference.batch_size = 8192
156
  denoise_param_path = os.path.join(config.output_dir, 'denoised.pt')
157
  primx_ckpt_weight = torch.load(denoise_param_path, map_location='cpu')['model_state_dict']
158
  model_primx.load_state_dict(primx_ckpt_weight)
 
199
  input_seed = gr.Slider(label="random seed", minimum=0, maximum=10000, step=1, value=42, info="Try different seed if the result is not satisfying as this is a generative model!")
200
  # gen button
201
  button_gen = gr.Button(value="Generate", interactive=False)
202
+ with gr.Row():
203
+ input_mc_resolution = gr.Radio(choices=[32, 64, 128, 256], label="MC Resolution", value=128, info="Cube resolution for mesh extraction")
204
+ input_remesh = gr.Radio(choices=["No", "Yes"], label="Remesh", value="No", info="Remesh or not?")
205
  export_glb_btn = gr.Button(value="Export GLB", interactive=False)
206
 
207
  with gr.Column(scale=1):
 
247
 
248
  input_image.change(background_remove_process, inputs=[input_image], outputs=[button_gen, current_fg_state, removal_previewer])
249
  button_gen.click(process, inputs=[current_fg_state, input_num_steps, input_seed, input_cfg], outputs=[output_rgb_video, output_prim_video, output_mat_video, export_glb_btn])
250
+ export_glb_btn.click(export_mesh, inputs=[input_remesh, input_mc_resolution], outputs=[output_glb, hdr_row])
251
 
252
  gr.Examples(
253
  examples=[
assets/examples/bubble_mart_blue.png DELETED
Binary file (212 kB)