import gradio as gr from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("mrm8488/flan-t5-small-finetuned-samsum") model = AutoModelForSeq2SeqLM.from_pretrained("mrm8488/flan-t5-small-finetuned-samsum") def predict_sentiment(input: Input): input_ids = tokenizer(input.text, return_tensors="pt").input_ids outputs = model.generate(input_ids, max_length=30) return tokenizer.decode(outputs[0], skip_special_tokens=True) iface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text") iface.launch()