Humphreykowl commited on
Commit
4badad0
·
verified ·
1 Parent(s): 7274424

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -10,6 +10,10 @@ import time
10
  import random
11
  import warnings
12
 
 
 
 
 
13
  # 抑制警告
14
  warnings.filterwarnings("ignore")
15
 
@@ -400,23 +404,26 @@ def create_gradio_interface():
400
  with gr.Row():
401
  cleanup_btn = gr.Button("清理内存", variant="secondary")
402
 
403
- # 事件绑定
404
  analyze_btn.click(
405
  fn=upload_and_analyze,
406
  inputs=[image_input],
407
- outputs=[analysis_output, suggestions_output, suggestion_choice]
 
408
  )
409
 
410
  generate_designs_btn.click(
411
  fn=generate_designs,
412
  inputs=[suggestion_choice],
413
- outputs=[designs_gallery, design_choice]
 
414
  )
415
 
416
  generate_3d_btn.click(
417
  fn=generate_3d_fitting,
418
  inputs=[design_choice],
419
- outputs=[fitting_result]
 
420
  )
421
 
422
  cleanup_btn.click(
@@ -436,13 +443,12 @@ if __name__ == "__main__":
436
 
437
  # 创建并启动界面
438
  demo = create_gradio_interface()
439
- demo.queue(
440
- concurrency_count=1, # 限制并发
441
- max_size=10 # 队列大小
442
- )
443
  demo.launch(
444
  server_name="0.0.0.0",
445
  server_port=7860,
446
  share=False, # 在Spaces环境中设为False
447
- show_error=True
 
448
  )
 
10
  import random
11
  import warnings
12
 
13
+ # 设置环境变量解决 OpenMP 问题
14
+ os.environ['OMP_NUM_THREADS'] = '1'
15
+ os.environ['MKL_NUM_THREADS'] = '1'
16
+
17
  # 抑制警告
18
  warnings.filterwarnings("ignore")
19
 
 
404
  with gr.Row():
405
  cleanup_btn = gr.Button("清理内存", variant="secondary")
406
 
407
+ # 事件绑定 - 使用新的 concurrency_limit 参数
408
  analyze_btn.click(
409
  fn=upload_and_analyze,
410
  inputs=[image_input],
411
+ outputs=[analysis_output, suggestions_output, suggestion_choice],
412
+ concurrency_limit=1
413
  )
414
 
415
  generate_designs_btn.click(
416
  fn=generate_designs,
417
  inputs=[suggestion_choice],
418
+ outputs=[designs_gallery, design_choice],
419
+ concurrency_limit=1
420
  )
421
 
422
  generate_3d_btn.click(
423
  fn=generate_3d_fitting,
424
  inputs=[design_choice],
425
+ outputs=[fitting_result],
426
+ concurrency_limit=1
427
  )
428
 
429
  cleanup_btn.click(
 
443
 
444
  # 创建并启动界面
445
  demo = create_gradio_interface()
446
+
447
+ # 启动应用 - 移除废弃的 queue 配置
 
 
448
  demo.launch(
449
  server_name="0.0.0.0",
450
  server_port=7860,
451
  share=False, # 在Spaces环境中设为False
452
+ show_error=True,
453
+ max_threads=2 # 限制线程数
454
  )