pipeline1 / impresso_langident_wrapper.py
Gleb Vinarskis
loading model
c746e15
raw
history blame
730 Bytes
from transformers import Pipeline
from transformers.pipelines import PIPELINE_REGISTRY
import floret
class Pipeline_One(Pipeline):
def __init__(self, model_path, **kwargs):
super().__init__(**kwargs) # Call the base class constructor
# Load the Floret model
self.model = floret.load_model(model_path)
def _sanitize_parameters(self, **kwargs):
# Add any additional parameter handling if necessary
return {}, {}, {}
def preprocess(self, text, **kwargs):
return text
def _forward(self, inputs):
model_output = self.model.predict(**inputs, k=1)
return model_output
def postprocess(self, outputs, **kwargs):
return outputs