LiuZichen commited on
Commit
644a908
·
verified ·
1 Parent(s): 5e2ed9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -226,7 +226,8 @@ with gr.Blocks() as app:
226
  fn=guess,
227
  inputs=[dg_input_img, dg_color_img, dg_edge_img],
228
  outputs=dg_output,
229
- api_name="guess_prompt"
 
230
  )
231
 
232
  with gr.Tab("SAM Segmentation"):
@@ -246,7 +247,8 @@ with gr.Blocks() as app:
246
  fn=segment,
247
  inputs=[sam_input_img, sam_pos_coords, sam_neg_coords, sam_bboxes],
248
  outputs=[sam_output_img, sam_output_bbox],
249
- api_name="segment"
 
250
  )
251
 
252
  if __name__ == "__main__":
@@ -255,9 +257,9 @@ if __name__ == "__main__":
255
 
256
  # Initialize SAM Pool
257
  # Adjust max_workers based on GPU memory (e.g., 2-4 workers for SAM-B)
258
- NUM_SAM_WORKERS = 5
259
  print(f"Starting {NUM_SAM_WORKERS} SAM worker processes...")
260
  sam_pool = ProcessPoolExecutor(max_workers=NUM_SAM_WORKERS, initializer=init_worker_sam)
261
 
262
  # Launch Gradio
263
- app.queue(max_size=40).launch(max_threads=5)
 
226
  fn=guess,
227
  inputs=[dg_input_img, dg_color_img, dg_edge_img],
228
  outputs=dg_output,
229
+ api_name="guess_prompt",
230
+ concurrency_limit=1
231
  )
232
 
233
  with gr.Tab("SAM Segmentation"):
 
247
  fn=segment,
248
  inputs=[sam_input_img, sam_pos_coords, sam_neg_coords, sam_bboxes],
249
  outputs=[sam_output_img, sam_output_bbox],
250
+ api_name="segment",
251
+ concurrency_limit=10
252
  )
253
 
254
  if __name__ == "__main__":
 
257
 
258
  # Initialize SAM Pool
259
  # Adjust max_workers based on GPU memory (e.g., 2-4 workers for SAM-B)
260
+ NUM_SAM_WORKERS = 10
261
  print(f"Starting {NUM_SAM_WORKERS} SAM worker processes...")
262
  sam_pool = ProcessPoolExecutor(max_workers=NUM_SAM_WORKERS, initializer=init_worker_sam)
263
 
264
  # Launch Gradio
265
+ app.queue(max_size=40).launch(max_threads=10)