Commit
·
7fb7cd0
1
Parent(s):
cb03a30
set self.metric
Browse files- pipeline.py +2 -2
pipeline.py
CHANGED
|
@@ -6,7 +6,7 @@ import json
|
|
| 6 |
import numpy as np
|
| 7 |
from fastai.learner import load_learner
|
| 8 |
|
| 9 |
-
|
| 10 |
class OrdinalRegressionMetric(Metric):
|
| 11 |
def __init__(self):
|
| 12 |
super().__init__()
|
|
@@ -46,7 +46,6 @@ class OrdinalRegressionMetric(Metric):
|
|
| 46 |
# Calculate the normalized metric value
|
| 47 |
metric_value = 1/(self.total / self.count)
|
| 48 |
return metric_value
|
| 49 |
-
"""
|
| 50 |
|
| 51 |
class PreTrainedPipeline():
|
| 52 |
def __init__(self, path=""):
|
|
@@ -54,6 +53,7 @@ class PreTrainedPipeline():
|
|
| 54 |
# Preload all the elements you are going to need at inference.
|
| 55 |
# For instance your model, processors, tokenizer that might be needed.
|
| 56 |
# This function is only called once, so do all the heavy processing I/O here"""
|
|
|
|
| 57 |
self.model = load_learner(os.path.join(path, "textfile3-2.pk1"))
|
| 58 |
with open(os.path.join(path, "config.json")) as config:
|
| 59 |
config = json.load(config)
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
from fastai.learner import load_learner
|
| 8 |
|
| 9 |
+
|
| 10 |
class OrdinalRegressionMetric(Metric):
|
| 11 |
def __init__(self):
|
| 12 |
super().__init__()
|
|
|
|
| 46 |
# Calculate the normalized metric value
|
| 47 |
metric_value = 1/(self.total / self.count)
|
| 48 |
return metric_value
|
|
|
|
| 49 |
|
| 50 |
class PreTrainedPipeline():
|
| 51 |
def __init__(self, path=""):
|
|
|
|
| 53 |
# Preload all the elements you are going to need at inference.
|
| 54 |
# For instance your model, processors, tokenizer that might be needed.
|
| 55 |
# This function is only called once, so do all the heavy processing I/O here"""
|
| 56 |
+
self.metric = OrdinalRegressionMetric()
|
| 57 |
self.model = load_learner(os.path.join(path, "textfile3-2.pk1"))
|
| 58 |
with open(os.path.join(path, "config.json")) as config:
|
| 59 |
config = json.load(config)
|