automatethem commited on
Commit
89c5d08
·
1 Parent(s): 1653855

Delete lib_pipeline.py

Browse files
Files changed (1) hide show
  1. lib_pipeline.py +0 -33
lib_pipeline.py DELETED
@@ -1,33 +0,0 @@
1
- from huggingface_hub import snapshot_download
2
- import pickle
3
-
4
- class TabularRegressionPipeLine():
5
- @classmethod
6
- def from_pretrained(cls, model_path):
7
- model = cls(model_path)
8
- return model
9
-
10
- def __init__(self, model_path):
11
- super().__init__()
12
- download_model_path = snapshot_download(model_path)
13
- #print(download_model_path) #/root/.cache/huggingface/hub/models--automatethem--com--son--height--tabular--regression--scikit--learn/snapshots/3ec6a8d12b818f998494c1ded1db7887cdaa57f1
14
- with open(f'{download_model_path}/model.pkl', 'rb') as f:
15
- self.model = pickle.load(f)
16
-
17
- def __call__(self, inputs):
18
- model_inputs = self.preprocess(inputs)
19
- model_outputs = self._forward(model_inputs)
20
- results = self.postprocess(model_outputs)
21
- return results
22
-
23
- def preprocess(self, inputs):
24
- return inputs
25
-
26
- def _forward(self, model_inputs):
27
- return self.model.predict(model_inputs)
28
-
29
- def postprocess(self, model_outputs):
30
- results = []
31
- for logit in model_outputs:
32
- results.append({'logit': logit})
33
- return results