hawk-monitor / app.py
cta2106
initial commit
38d4932
raw
history blame
472 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()