Skip to content

armgit / rembg

Public Imported from GitHub
0

Rembg is a tool to remove images background

refact

Daniel Gatise67c6407dd49
diff --git a/rembg/detect.py b/rembg/detect.py
index 5bd6e25..e71a2d4 100644
--- a/rembg/detect.py
+++ b/rembg/detect.py
@@ -36,15 +36,16 @@ def ort_session(model_name: str) -> ort.InferenceSession:
if hashing.hexdigest() != md5:
with redirect_stdout(sys.stderr):
gdown.download(url, str(path), use_cookies=False)
-
+
+ sess_opts = ort.SessionOptions()
+
if "OMP_NUM_THREADS" in os.environ:
- sess_opts = ort.SessionOptions()
- sess_opts.inter_op_num_threads = int(os.environ["OMP_NUM_THREADS"])
- sess_opts.intra_op_num_threads = int(os.environ["OMP_NUM_THREADS"])
- else:
- sess_opts=None
-
- return ort.InferenceSession(str(path), providers=ort.get_available_providers(), sess_options=sess_opts)
+ sess_opts.inter_op_num_threads = int(os.environ["OMP_NUM_THREADS"])
+ sess_opts.intra_op_num_threads = int(os.environ["OMP_NUM_THREADS"])
+
+ return ort.InferenceSession(
+ str(path), providers=ort.get_available_providers(), sess_options=sess_opts
+ )
def norm_pred(d: np.ndarray) -> np.ndarray: