Doron Adler commited on
Commit
8b4ec72
1 Parent(s): 46bda0c

Limit onnx runtime to 1 thread

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
- os.system("pip install --upgrade pip")
 
3
  import onnxruntime as rt
4
- os.system("pip install dlib")
5
  import sys
6
  import PIL
7
  from PIL import Image, ImageOps, ImageFile
@@ -14,7 +14,9 @@ import requests
14
  import face_detection
15
 
16
  MODEL_FILE = "comics-heroes_p2s2p_model_from_scripted-simp.quant.onnx"
17
- session = rt.InferenceSession(MODEL_FILE)
 
 
18
  input_name = session.get_inputs()[0].name
19
  print("input_name = " + str(input_name))
20
  output_name = session.get_outputs()[0].name
 
1
  import os
2
+ #os.system("pip install --upgrade pip")
3
+ #os.system("pip install dlib")
4
  import onnxruntime as rt
 
5
  import sys
6
  import PIL
7
  from PIL import Image, ImageOps, ImageFile
 
14
  import face_detection
15
 
16
  MODEL_FILE = "comics-heroes_p2s2p_model_from_scripted-simp.quant.onnx"
17
+ so = rt.SessionOptions()
18
+ so.inter_op_num_threads = 1
19
+ session = rt.InferenceSession(MODEL_FILE, sess_options=so)
20
  input_name = session.get_inputs()[0].name
21
  print("input_name = " + str(input_name))
22
  output_name = session.get_outputs()[0].name