ABAO77 commited on
Commit
ebd9a0d
·
1 Parent(s): d0a3171

[refactor][abaomxomtieu]: put model out scrop of inference function

Browse files
Files changed (1) hide show
  1. src/inference/segment_inference.py +6 -9
src/inference/segment_inference.py CHANGED
@@ -2,11 +2,13 @@ import onnxruntime as ort
2
  from src.utils.utils_segment import preprocess, postprocess
3
  import numpy as np
4
 
 
 
 
 
5
 
6
- def inference(image: np.array, model_path, threshold_confidence=0.5, threshold_iou=0.7):
7
- model = ort.InferenceSession(
8
- model_path,
9
- )
10
  input = preprocess(image)
11
  outputs = postprocess(
12
  model.run(None, {"images": input}),
@@ -16,8 +18,3 @@ def inference(image: np.array, model_path, threshold_confidence=0.5, threshold_i
16
 
17
  return outputs
18
 
19
-
20
- if __name__ == "__main__":
21
- model_path = "../model/segment.onnx"
22
- image_path = "../../test.jpg"
23
- print(inference(image_path, model_path))
 
2
  from src.utils.utils_segment import preprocess, postprocess
3
  import numpy as np
4
 
5
+ model_path = "./src/model/segment.onnx"
6
+ model = ort.InferenceSession(
7
+ model_path,
8
+ )
9
 
10
+
11
+ def inference(image: np.array, threshold_confidence=0.5, threshold_iou=0.7):
 
 
12
  input = preprocess(image)
13
  outputs = postprocess(
14
  model.run(None, {"images": input}),
 
18
 
19
  return outputs
20