hawk-monitor / app.py
cta2106
fixing
50c2eab
raw
history blame
476 Bytes
from transformers import pipeline, LongformerForSequenceClassification, LongformerTokenizer, Trainer
import gradio as gr
def predict_fn(text: str) -> str:
model = LongformerForSequenceClassification.from_pretrained("model")
tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-base-4096")
p = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
return p(text)[0]["label"]
gr.Interface(predict_fn, "textbox", "label").launch()