osanseviero
commited on
Commit
·
f479f1f
1
Parent(s):
70c0533
Update pipeline.py
Browse files- pipeline.py +0 -4
pipeline.py
CHANGED
@@ -8,15 +8,12 @@ from fastai.learner import load_learner
|
|
8 |
|
9 |
from helpers import is_cat
|
10 |
|
11 |
-
def is_cat(x): return x[0].isupper()
|
12 |
-
|
13 |
class PreTrainedPipeline():
|
14 |
def __init__(self, path=""):
|
15 |
# IMPLEMENT_THIS
|
16 |
# Preload all the elements you are going to need at inference.
|
17 |
# For instance your model, processors, tokenizer that might be needed.
|
18 |
# This function is only called once, so do all the heavy processing I/O here"""
|
19 |
-
def is_cat(x): return x[0].isupper()
|
20 |
self.model = load_learner(os.path.join(path, "model.pkl"))
|
21 |
with open(os.path.join(path, "config.json")) as config:
|
22 |
config = json.load(config)
|
@@ -32,7 +29,6 @@ class PreTrainedPipeline():
|
|
32 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
33 |
It is preferred if the returned list is in decreasing `score` order
|
34 |
"""
|
35 |
-
def is_cat(x): return x[0].isupper()
|
36 |
# IMPLEMENT_THIS
|
37 |
# FastAI expects a np array, not a PIL Image.
|
38 |
_, _, preds = self.model.predict(np.array(inputs))
|
|
|
8 |
|
9 |
from helpers import is_cat
|
10 |
|
|
|
|
|
11 |
class PreTrainedPipeline():
|
12 |
def __init__(self, path=""):
|
13 |
# IMPLEMENT_THIS
|
14 |
# Preload all the elements you are going to need at inference.
|
15 |
# For instance your model, processors, tokenizer that might be needed.
|
16 |
# This function is only called once, so do all the heavy processing I/O here"""
|
|
|
17 |
self.model = load_learner(os.path.join(path, "model.pkl"))
|
18 |
with open(os.path.join(path, "config.json")) as config:
|
19 |
config = json.load(config)
|
|
|
29 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
30 |
It is preferred if the returned list is in decreasing `score` order
|
31 |
"""
|
|
|
32 |
# IMPLEMENT_THIS
|
33 |
# FastAI expects a np array, not a PIL Image.
|
34 |
_, _, preds = self.model.predict(np.array(inputs))
|