Commit
·
8305005
1
Parent(s):
aaaa4f9
Create pipeline.py
Browse files- pipeline.py +28 -0
pipeline.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, List, Union
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
class PreTrainedPipeline():
|
| 5 |
+
def __init__(self, path=""):
|
| 6 |
+
# IMPLEMENT_THIS
|
| 7 |
+
# Preload all the elements you are going to need at inference.
|
| 8 |
+
# For instance your model, processors, tokenizer that might be needed.
|
| 9 |
+
# This function is only called once, so do all the heavy processing I/O here"""
|
| 10 |
+
raise NotImplementedError(
|
| 11 |
+
"Please implement PreTrainedPipeline __init__ function"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
def __call__(
|
| 15 |
+
self, inputs: Dict[str, Dict[str, List[Union[str, float]]]]
|
| 16 |
+
) -> List[Union[str, float]]:
|
| 17 |
+
"""
|
| 18 |
+
Args:
|
| 19 |
+
inputs (:obj:`dict`):
|
| 20 |
+
a dictionary containing a key 'data' mapping to a dict in which
|
| 21 |
+
the values represent each column.
|
| 22 |
+
Return:
|
| 23 |
+
A :obj:`list` of floats or strings: The classification output for each row.
|
| 24 |
+
"""
|
| 25 |
+
# IMPLEMENT_THIS
|
| 26 |
+
raise NotImplementedError(
|
| 27 |
+
"Please implement PreTrainedPipeline __call__ function"
|
| 28 |
+
)
|