Skip to content

Commit

Permalink
remove chdir jank
Browse files Browse the repository at this point in the history
  • Loading branch information
mertalev committed Mar 15, 2024
1 parent 093c89f commit c20f8d5
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions machine-learning/app/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,12 @@ def _make_session(self, model_path: Path) -> AnnSession | ort.InferenceSession:
case ".armnn":
session = AnnSession(model_path)
case ".onnx":
cwd = os.getcwd()
try:
os.chdir(model_path.parent)
session = ort.InferenceSession(
model_path.as_posix(),
sess_options=self.sess_options,
providers=self.providers,
provider_options=self.provider_options,
)
finally:
os.chdir(cwd)
session = ort.InferenceSession(
model_path.as_posix(),
sess_options=self.sess_options,
providers=self.providers,
provider_options=self.provider_options,
)
case _:
raise ValueError(f"Unsupported model file type: {model_path.suffix}")
return session
Expand Down

0 comments on commit c20f8d5

Please sign in to comment.