hawk-monitor / app.py
cta2106
fixed output
b2830ea
raw
history blame
473 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)["label"]
gr.Interface(predict_fn, "textbox", "label").launch()