dawoodkhan82 commited on
Commit
2db75b1
1 Parent(s): cf814c2
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -133,7 +133,6 @@ def do_inference(input_3d, sample_seed=0, do_sampling=False, do_marching_cubes=F
133
  mesh.visual.vertex_colors = np.tile(orange_color, (mesh.vertices.shape[0], 1))
134
  input_save_name = f"processed_input_{int(time.time())}.obj"
135
  mesh.export(input_save_name)
136
- input_render_res = wireframe_render(mesh)
137
 
138
  pc_coor = pc_coor / np.abs(pc_coor).max() * 0.9995 # input should be from -1 to 1
139
  assert (np.linalg.norm(normals, axis=-1) > 0.99).all(), "normals should be unit vectors, something wrong"
@@ -176,8 +175,7 @@ def do_inference(input_3d, sample_seed=0, do_sampling=False, do_marching_cubes=F
176
  # add time stamp to avoid cache
177
  save_name = f"output_{int(time.time())}.obj"
178
  artist_mesh.export(save_name)
179
- output_render = wireframe_render(artist_mesh)
180
- return input_save_name, input_render_res, save_name, output_render
181
 
182
 
183
  _HEADER_ = '''
@@ -215,11 +213,15 @@ preprocess_model_obj = gr.Model3D(
215
  label="Processed Input Mesh (OBJ Format)",
216
  clear_color=[1, 1, 1, 1],
217
  )
218
- input_image_render = gr.Image(
219
- label="Wireframe Render of Processed Input Mesh",
220
- )
221
- output_image_render = gr.Image(
 
 
222
  label="Wireframe Render of Generated Mesh",
 
 
223
  )
224
  with (gr.Blocks() as demo):
225
  gr.Markdown(_HEADER_)
@@ -246,19 +248,19 @@ with (gr.Blocks() as demo):
246
  os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
247
  ],
248
  inputs=input_3d,
249
- outputs=[preprocess_model_obj, input_image_render, output_model_obj, output_image_render],
250
  fn=do_inference,
251
  cache_examples = "lazy",
252
  examples_per_page=10
253
  )
254
  with gr.Column():
255
  with gr.Row():
256
- input_image_render.render()
257
  with gr.Row():
258
  with gr.Tab("OBJ"):
259
  preprocess_model_obj.render()
260
  with gr.Row():
261
- output_image_render.render()
262
  with gr.Row():
263
  with gr.Tab("OBJ"):
264
  output_model_obj.render()
@@ -272,7 +274,7 @@ with (gr.Blocks() as demo):
272
  submit.click(
273
  fn=do_inference,
274
  inputs=[input_3d, sample_seed, do_sampling, do_marching_cubes],
275
- outputs=[preprocess_model_obj, input_image_render, output_model_obj, output_image_render],
276
  )
277
 
278
  demo.launch(share=True)
 
133
  mesh.visual.vertex_colors = np.tile(orange_color, (mesh.vertices.shape[0], 1))
134
  input_save_name = f"processed_input_{int(time.time())}.obj"
135
  mesh.export(input_save_name)
 
136
 
137
  pc_coor = pc_coor / np.abs(pc_coor).max() * 0.9995 # input should be from -1 to 1
138
  assert (np.linalg.norm(normals, axis=-1) > 0.99).all(), "normals should be unit vectors, something wrong"
 
175
  # add time stamp to avoid cache
176
  save_name = f"output_{int(time.time())}.obj"
177
  artist_mesh.export(save_name)
178
+ return input_save_name, input_save_name, save_name, save_name
 
179
 
180
 
181
  _HEADER_ = '''
 
213
  label="Processed Input Mesh (OBJ Format)",
214
  clear_color=[1, 1, 1, 1],
215
  )
216
+ input_wireframe_render = gr.Model3D(
217
+ label="Wireframe Render of Processed Input Mesh",
218
+ clear_color=[1,1,1,1],
219
+ display_mode="wireframe"
220
+ )
221
+ output_wireframe_render = gr.Model3D(
222
  label="Wireframe Render of Generated Mesh",
223
+ clear_color=[1, 1, 1, 1],
224
+ display_mode="wireframe"
225
  )
226
  with (gr.Blocks() as demo):
227
  gr.Markdown(_HEADER_)
 
248
  os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
249
  ],
250
  inputs=input_3d,
251
+ outputs=[preprocess_model_obj, input_wireframe_render, output_model_obj, output_wireframe_render],
252
  fn=do_inference,
253
  cache_examples = "lazy",
254
  examples_per_page=10
255
  )
256
  with gr.Column():
257
  with gr.Row():
258
+ input_wireframe_render.render()
259
  with gr.Row():
260
  with gr.Tab("OBJ"):
261
  preprocess_model_obj.render()
262
  with gr.Row():
263
+ output_wireframe_render.render()
264
  with gr.Row():
265
  with gr.Tab("OBJ"):
266
  output_model_obj.render()
 
274
  submit.click(
275
  fn=do_inference,
276
  inputs=[input_3d, sample_seed, do_sampling, do_marching_cubes],
277
+ outputs=[preprocess_model_obj, input_wireframe_render, output_model_obj, output_wireframe_render],
278
  )
279
 
280
  demo.launch(share=True)