radames commited on
Commit
a80cb41
1 Parent(s): 199f296

set 1 min timeout

Browse files
Files changed (1) hide show
  1. visualizer_drag_gradio.py +9 -1
visualizer_drag_gradio.py CHANGED
@@ -5,6 +5,7 @@ import os.path as osp
5
  from argparse import ArgumentParser
6
  from functools import partial
7
  from pathlib import Path
 
8
 
9
  import gradio as gr
10
  import numpy as np
@@ -34,6 +35,7 @@ cache_dir = args.cache_dir
34
 
35
  device = 'cuda'
36
  IS_SPACE = "DragGan/DragGan" in os.environ.get('SPACE_ID', '')
 
37
 
38
 
39
  def reverse_point_pairs(points):
@@ -553,7 +555,13 @@ with gr.Blocks() as app:
553
  print(f' Source: {p_in_pixels}')
554
  print(f' Target: {t_in_pixels}')
555
  step_idx = 0
 
556
  while True:
 
 
 
 
 
557
  if global_state["temporal_params"]["stop"]:
558
  break
559
 
@@ -907,5 +915,5 @@ with gr.Blocks() as app:
907
 
908
  print("SHAReD: Start app", parser.parse_args())
909
  gr.close_all()
910
- app.queue(concurrency_count=2, max_size=200, api_open=False)
911
  app.launch(share=args.share, show_api=False)
 
5
  from argparse import ArgumentParser
6
  from functools import partial
7
  from pathlib import Path
8
+ import time
9
 
10
  import gradio as gr
11
  import numpy as np
 
35
 
36
  device = 'cuda'
37
  IS_SPACE = "DragGan/DragGan" in os.environ.get('SPACE_ID', '')
38
+ TIMEOUT = 60 if IS_SPACE else 0
39
 
40
 
41
  def reverse_point_pairs(points):
 
555
  print(f' Source: {p_in_pixels}')
556
  print(f' Target: {t_in_pixels}')
557
  step_idx = 0
558
+ last_time = time.time()
559
  while True:
560
+ # add a TIMEOUT break
561
+ print(f'Running time: {time.time() - last_time}')
562
+ if time.time() - last_time > TIMEOUT:
563
+ print('Timeout break!')
564
+ break
565
  if global_state["temporal_params"]["stop"]:
566
  break
567
 
 
915
 
916
  print("SHAReD: Start app", parser.parse_args())
917
  gr.close_all()
918
+ app.queue(concurrency_count=3, max_size=200, api_open=False)
919
  app.launch(share=args.share, show_api=False)