Create pipeline.py
Browse files- pipeline.py +22 -0
pipeline.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class PreTrainedPipeline():
|
2 |
+
def __init__(self, path=""):
|
3 |
+
# IMPLEMENT_THIS
|
4 |
+
# Preload all the elements you are going to need at inference.
|
5 |
+
# For instance your model, processors, tokenizer that might be needed.
|
6 |
+
# This function is only called once, so do all the heavy processing I/O here"""
|
7 |
+
raise NotImplementedError(
|
8 |
+
"Please implement PreTrainedPipeline __init__ function"
|
9 |
+
)
|
10 |
+
|
11 |
+
def __call__(self, inputs: str):
|
12 |
+
"""
|
13 |
+
Args:
|
14 |
+
inputs (:obj:`str`):
|
15 |
+
a string containing some text
|
16 |
+
Return:
|
17 |
+
A :obj:`PIL.Image` with the raw image representation as PIL.
|
18 |
+
"""
|
19 |
+
# IMPLEMENT_THIS
|
20 |
+
raise NotImplementedError(
|
21 |
+
"Please implement PreTrainedPipeline __call__ function"
|
22 |
+
)
|