Wagner Bruna commited on
Commit
782d7bb
·
1 Parent(s): c338bd3

config inference timeout

Browse files
Files changed (2) hide show
  1. app.py +2 -4
  2. config.py +3 -0
app.py CHANGED
@@ -95,9 +95,7 @@ def extract_params_inference(params):
95
 
96
  return kwargs, save_params
97
 
98
- inference_timeout=300.0
99
-
100
- def call_text_to_image_api(params, timeout=inference_timeout, token=None):
101
  if cfg.DEBUG: print('call_text_to_image_api:', params)
102
  kwargs , save_params = extract_params_inference(params)
103
  client = InferenceClient(token=token)
@@ -121,7 +119,7 @@ def infer_api_fn(progress=gr.Progress(), previouslist=None, *args):
121
  if not model_str or model_str == 'NA':
122
  return None
123
 
124
- kwargs = {'timeout':inference_timeout}
125
  if cfg.HF_TOKEN_SD:
126
  kwargs.update(token=cfg.HF_TOKEN_SD)
127
 
 
95
 
96
  return kwargs, save_params
97
 
98
+ def call_text_to_image_api(params, timeout=cfg.INFERENCE_TIMEOUT, token=None):
 
 
99
  if cfg.DEBUG: print('call_text_to_image_api:', params)
100
  kwargs , save_params = extract_params_inference(params)
101
  client = InferenceClient(token=token)
 
119
  if not model_str or model_str == 'NA':
120
  return None
121
 
122
+ kwargs = {'timeout':cfg.INFERENCE_TIMEOUT}
123
  if cfg.HF_TOKEN_SD:
124
  kwargs.update(token=cfg.HF_TOKEN_SD)
125
 
config.py CHANGED
@@ -21,3 +21,6 @@ MODEL_LIST = os.environ.get('MODEL_LIST', '').split(',')
21
  # edit: enable editing the field
22
  EDIT_MODELS = os.environ.get('EDIT_MODELS', '').split(',')
23
 
 
 
 
 
21
  # edit: enable editing the field
22
  EDIT_MODELS = os.environ.get('EDIT_MODELS', '').split(',')
23
 
24
+ # inference timeout, in seconds
25
+ INFERENCE_TIMEOUT = float(os.environ.get('INFERENCE_TIMEOUT', '300'))
26
+