Spaces:
Sleeping
Sleeping
File size: 815 Bytes
661c5c9 4230c01 28bac9d 661c5c9 28bac9d 769a6fc 28bac9d 769a6fc 28bac9d 769a6fc 63e67d2 28bac9d afdf68a 28bac9d afdf68a 661c5c9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from pydantic import BaseModel
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")
class Input(BaseModel):
text: str
def predict_sentiment(input: Input, words):
input_ids = tokenizer(input.text, return_tensors="pt").input_ids
outputs = model.generate(input_ids, max_length=words)
decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
return f"{decoded_output}"
conversation = gr.Textbox(lines=2, placeholder="Conversations Here...")
iface = gr.Interface(fn=predict_sentiment, inputs=[Input(text=conversation), gr.Slider(10, 100)], outputs="text")
iface.launch() |