File size: 1,331 Bytes
d1f6f7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
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()