Token Classification
GLiNER
PyTorch
English
gliner-custom / handler.py
Manu Biot
Add requirements.txt for endpoint dependencies
ca90b41
raw
history blame contribute delete
438 Bytes
from gliner import GLiNER
from typing import Dict, List, Any
class EndpointHandler():
def __init__(self, path=""):
self.model = GLiNER.from_pretrained(path)
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
# get inputs
inputs = data.pop("inputs", data)
labels = data.pop("labels", None)
prediction = self.model.predict_entities(inputs, labels)
return prediction