jpohhhh commited on
Commit
df00d4a
·
1 Parent(s): dbdba21

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +4 -2
handler.py CHANGED
@@ -4,7 +4,7 @@ from optimum.pipelines import pipeline
4
  from optimum.onnxruntime import ORTModelForFeatureExtraction
5
  from pathlib import Path
6
 
7
-
8
  import torch
9
 
10
  #Mean Pooling - Take attention mask into account for correct averaging
@@ -15,10 +15,12 @@ def mean_pooling(model_output, attention_mask):
15
 
16
  class EndpointHandler():
17
  def __init__(self, path=""):
 
 
18
  # self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
19
  task = "feature-extraction"
20
  tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/msmarco-MiniLM-L-6-v3')
21
- model_regular = ORTModelForFeatureExtraction.from_pretrained(Path("onnx"), file_name="model.onnx", from_transformers=False)
22
  self.onnx_extractor = pipeline(task, model=model_regular, tokenizer=tokenizer)
23
  # self.model.to(self.device)
24
  # print("model will run on ", self.device)
 
4
  from optimum.onnxruntime import ORTModelForFeatureExtraction
5
  from pathlib import Path
6
 
7
+ import os
8
  import torch
9
 
10
  #Mean Pooling - Take attention mask into account for correct averaging
 
15
 
16
  class EndpointHandler():
17
  def __init__(self, path=""):
18
+ print("HELLO THIS IS THE CWD:", os.getcwd())
19
+ print("HELLO THIS IS THE PATH ARG:", path)
20
  # self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
21
  task = "feature-extraction"
22
  tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/msmarco-MiniLM-L-6-v3')
23
+ model_regular = ORTModelForFeatureExtraction.from_pretrained(Path(path / "onnx"), file_name="model.onnx", from_transformers=False)
24
  self.onnx_extractor = pipeline(task, model=model_regular, tokenizer=tokenizer)
25
  # self.model.to(self.device)
26
  # print("model will run on ", self.device)