Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline | |
# Load model | |
model_name = "Manish014/review-summariser-gpt-config1" | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer) | |
# Define Gradio UI | |
def summarize_review(review): | |
if not review.strip(): | |
return "Please enter a review." | |
output = summarizer(review, max_length=60, min_length=10, do_sample=False) | |
return output[0]["summary_text"] | |
examples = [ | |
["This is the worst coffee maker I’ve ever used. It leaks water everywhere, the buttons barely work, and the brew tastes like plastic."], | |
["Great product! Easy to use, super fast delivery, and the quality is outstanding. Highly recommend!"], | |
["Battery life is average but display quality and sound are top-notch."], | |
["Not worth the money. Poor customer service and the build feels cheap."] | |
] | |
demo = gr.Interface( | |
fn=summarize_review, | |
inputs=gr.Textbox(lines=6, placeholder="Paste a product review here..."), | |
outputs="text", | |
examples=examples, | |
title="Review Summariser GPT", | |
description="Enter a product review to get a helpful summary using Config1 fine-tuned T5-small model." | |
) | |
demo.launch() | |