frogleo commited on
Commit
b28a26e
·
1 Parent(s): 548fc2d

优化输出参数

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -35,7 +35,7 @@ os.makedirs(SAVE_DIR, exist_ok=True)
35
 
36
  CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
37
 
38
- HTML_HEIGHT = 690
39
  HTML_WIDTH = 500
40
 
41
 
@@ -203,9 +203,10 @@ def gen_shape(
203
  mesh = face_reduce_worker(mesh, target_face_num)
204
  save_folder = gen_save_folder()
205
 
 
206
  file_type = "obj"
207
- objPath = export_mesh(mesh, save_folder, textured=False, type=file_type)
208
- rel_objPath = os.path.relpath(objPath, SAVE_DIR)
209
  objPath = "/static/"+rel_objPath
210
 
211
  # for preview
@@ -219,11 +220,8 @@ def gen_shape(
219
  glbPath = "/static/"+rel_glbPath
220
 
221
 
222
-
223
-
224
  progress(1,desc="Complete")
225
- return model_viewer_html, glbPath, objPath
226
-
227
 
228
 
229
 
@@ -233,7 +231,7 @@ def get_example_img_list():
233
  example_imgs = get_example_img_list()
234
 
235
  HTML_OUTPUT_PLACEHOLDER = f"""
236
- <div style='height: {650}px; width: 100%; border-radius: 8px; border-color: #e5e7eb; border-style: solid; border-width: 1px; display: flex; justify-content: center; align-items: center;'>
237
  <div style='text-align: center; font-size: 16px; color: #6b7280;'>
238
  <p style="color: #8d8d8d;">No mesh here.</p>
239
  </div>
@@ -274,8 +272,10 @@ with gr.Blocks().queue() as demo:
274
  with gr.Column(scale=6):
275
  gr.Markdown("#### Generated Mesh")
276
  html_export_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
277
- objPath_output = gr.Textbox(label="Obj Path")
278
- glbPath_output = gr.Textbox(label="Glb Path")
 
 
279
 
280
  with gr.Column(scale=3):
281
  gr.Markdown("#### Image Examples")
@@ -285,7 +285,7 @@ with gr.Blocks().queue() as demo:
285
  gen_button.click(
286
  fn=gen_shape,
287
  inputs=[image,num_steps,cfg_scale,seed,octree_resolution,num_chunks,target_face_num, randomize_seed],
288
- outputs=[html_export_mesh, glbPath_output, objPath_output]
289
  )
290
 
291
  # https://discuss.huggingface.co/t/how-to-serve-an-html-file/33921/2
 
35
 
36
  CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
37
 
38
+ HTML_HEIGHT = 500
39
  HTML_WIDTH = 500
40
 
41
 
 
203
  mesh = face_reduce_worker(mesh, target_face_num)
204
  save_folder = gen_save_folder()
205
 
206
+ progress(0.9,desc="Converting format")
207
  file_type = "obj"
208
+ sourceObjPath = export_mesh(mesh, save_folder, textured=False, type=file_type)
209
+ rel_objPath = os.path.relpath(sourceObjPath, SAVE_DIR)
210
  objPath = "/static/"+rel_objPath
211
 
212
  # for preview
 
220
  glbPath = "/static/"+rel_glbPath
221
 
222
 
 
 
223
  progress(1,desc="Complete")
224
+ return model_viewer_html, gr.update(value=sourceObjPath, interactive=True), glbPath, objPath
 
225
 
226
 
227
 
 
231
  example_imgs = get_example_img_list()
232
 
233
  HTML_OUTPUT_PLACEHOLDER = f"""
234
+ <div style='height: {500}px; width: 100%; border-radius: 8px; border-color: #e5e7eb; border-style: solid; border-width: 1px; display: flex; justify-content: center; align-items: center;'>
235
  <div style='text-align: center; font-size: 16px; color: #6b7280;'>
236
  <p style="color: #8d8d8d;">No mesh here.</p>
237
  </div>
 
272
  with gr.Column(scale=6):
273
  gr.Markdown("#### Generated Mesh")
274
  html_export_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
275
+ file_export = gr.DownloadButton(label="Download", variant='primary', interactive=False)
276
+ with gr.Row():
277
+ objPath_output = gr.Text(label="Obj Path",interactive=False)
278
+ glbPath_output = gr.Text(label="Glb Path",interactive=False)
279
 
280
  with gr.Column(scale=3):
281
  gr.Markdown("#### Image Examples")
 
285
  gen_button.click(
286
  fn=gen_shape,
287
  inputs=[image,num_steps,cfg_scale,seed,octree_resolution,num_chunks,target_face_num, randomize_seed],
288
+ outputs=[html_export_mesh,file_export, glbPath_output, objPath_output]
289
  )
290
 
291
  # https://discuss.huggingface.co/t/how-to-serve-an-html-file/33921/2