File size: 577 Bytes
661c5c9
28bac9d
661c5c9
28bac9d
 
 
 
 
 
 
 
 
 
 
 
661c5c9
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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()