from typing import Any, Tuple from transformers import pipeline, LongformerForSequenceClassification, LongformerTokenizer, Trainer import gradio as gr def predict_fn(text: str) -> Tuple[Any, Any]: model = LongformerForSequenceClassification.from_pretrained("model") tokenizer = LongformerTokenizer.from_pretrained("allenai/longformer-base-4096") p = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer) results = p(text) factor = 100 if results[0]['label'] == 'Hawkish' else -100 return results[0]['label'], round(results[0]['score'] * factor, 0) gr.Interface(predict_fn, "textbox", ["label", "label"]).launch()