Spaces:
Sleeping
Sleeping
File size: 1,233 Bytes
395eb19 54cc63b 395eb19 2328652 19e66b2 f022e05 395eb19 54cc63b 395eb19 77b38ba 395eb19 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import gradio as gr
model = AutoModelForSeq2SeqLM.from_pretrained("PRAli22/flan-t5-base-imdb-text-classification")
tokenizer = AutoTokenizer.from_pretrained("PRAli22/flan-t5-base-imdb-text-classification")
def summarize(text):
inputs = tokenizer.encode_plus(text, padding='max_length', max_length=512, return_tensors='pt')
summarized_ids = model.generate(inputs['input_ids'], attention_mask=inputs['attention_mask'],
max_length=150, num_beams=4, early_stopping=True)
return tokenizer.decode(summarized_ids[0], skip_special_tokens=True)
css_code='body{background-image:url("https://media.istockphoto.com/id/1256252051/vector/people-using-online-translation-app.jpg?s=612x612&w=0&k=20&c=aa6ykHXnSwqKu31fFR6r6Y1bYMS5FMAU9yHqwwylA94=");}'
demo = gr.Interface(
fn=summarize,
inputs=
gr.Textbox(label="text", placeholder="Enter the text "),
outputs=gr.Textbox(label="sentiment"),
title="Sentiment Classifier",
description= "This is Sentiment Classifier, it takes a text in English as inputs and returns the sentiment",
css = css_code
)
demo.launch() |