Lord-Raven commited on
Commit
d64cd1f
·
1 Parent(s): 6d2fab3

CPU fallback.

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -55,11 +55,12 @@ def classify(data_string, request: gradio.Request):
55
  try:
56
  if 'cpu' not in data:
57
  result = zero_shot_classification_gpu(data)
 
58
  except Exception as e:
59
  print(f"GPU classification failed: {e}\nFall back to CPU.")
60
  if not result:
61
- result = zero_shot_classification_gpu(data)
62
- print(f"Classification @ [{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] took {time.time() - start_time}.")
63
  return json.dumps(result)
64
 
65
  def zero_shot_classification_cpu(data):
 
55
  try:
56
  if 'cpu' not in data:
57
  result = zero_shot_classification_gpu(data)
58
+ print(f"GPU Classification @ [{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] took {time.time() - start_time}.")
59
  except Exception as e:
60
  print(f"GPU classification failed: {e}\nFall back to CPU.")
61
  if not result:
62
+ result = zero_shot_classification_cpu(data)
63
+ print(f"CPU Classification @ [{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] took {time.time() - start_time}.")
64
  return json.dumps(result)
65
 
66
  def zero_shot_classification_cpu(data):