andreidima
commited on
Commit
•
0c8843e
1
Parent(s):
890f826
Delete pipeline.py
Browse files- pipeline.py +0 -26
pipeline.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
2 |
-
|
3 |
-
class PreTrainedPipeline():
|
4 |
-
def __init__(self, path=""):
|
5 |
-
# IMPLEMENT_THIS
|
6 |
-
# Preload all the elements you are going to need at inference.
|
7 |
-
# For instance your model, processors, tokenizer that might be needed.
|
8 |
-
# This function is only called once, so do all the heavy processing I/O here"""
|
9 |
-
model = AutoModelForCausalLM.from_pretrained(path)
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(path)
|
11 |
-
|
12 |
-
self.pipe = pipeline(task="text-generation",
|
13 |
-
model=model,
|
14 |
-
tokenizer=tokenizer
|
15 |
-
)
|
16 |
-
|
17 |
-
def __call__(self, inputs):
|
18 |
-
"""
|
19 |
-
Args:
|
20 |
-
inputs (:obj:`np.array`):
|
21 |
-
The raw waveform of audio received. By default at 16KHz.
|
22 |
-
Return:
|
23 |
-
A :obj:`dict`:. The object return should be liked {"text": "XXX"} containing
|
24 |
-
the detected text from the input audio.
|
25 |
-
"""
|
26 |
-
return self.pipe(inputs)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|