Spaces:
Runtime error
Runtime error
senior-sigan
commited on
Commit
•
c80e463
1
Parent(s):
eea656e
fix onnxruntime "pthread_setaffinity_np failed" error
Browse files- encoder.py +5 -1
- generator.py +4 -1
encoder.py
CHANGED
@@ -22,7 +22,11 @@ class Encoder(object):
|
|
22 |
) -> None:
|
23 |
self.input_name = 'input_0'
|
24 |
self.output_name = 'output_0'
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
def predict(self, image: PIL.Image.Image) -> np.ndarray:
|
28 |
x = to_tensor(image)
|
|
|
22 |
) -> None:
|
23 |
self.input_name = 'input_0'
|
24 |
self.output_name = 'output_0'
|
25 |
+
|
26 |
+
opts = onnxruntime.SessionOptions()
|
27 |
+
opts.intra_op_num_threads = 8
|
28 |
+
self.session = onnxruntime.InferenceSession(
|
29 |
+
model_path, sess_options=opts)
|
30 |
|
31 |
def predict(self, image: PIL.Image.Image) -> np.ndarray:
|
32 |
x = to_tensor(image)
|
generator.py
CHANGED
@@ -18,7 +18,10 @@ class Generator(object):
|
|
18 |
) -> None:
|
19 |
self.input_name = 'input_0'
|
20 |
self.output_name = 'output_0'
|
21 |
-
|
|
|
|
|
|
|
22 |
|
23 |
def predict(self, x: np.ndarray) -> PIL.Image.Image:
|
24 |
x = np.expand_dims(x, 0)
|
|
|
18 |
) -> None:
|
19 |
self.input_name = 'input_0'
|
20 |
self.output_name = 'output_0'
|
21 |
+
opts = onnxruntime.SessionOptions()
|
22 |
+
opts.intra_op_num_threads = 8
|
23 |
+
self.session = onnxruntime.InferenceSession(
|
24 |
+
model_path, sess_options=opts)
|
25 |
|
26 |
def predict(self, x: np.ndarray) -> PIL.Image.Image:
|
27 |
x = np.expand_dims(x, 0)
|