Manish014 commited on
Commit
d1f6f7b
·
verified ·
1 Parent(s): 7a50246

create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
3
+
4
+ # Load model
5
+ model_name = "Manish014/review-summariser-gpt-config1"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
+
9
+ summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)
10
+
11
+ # Define Gradio UI
12
+ def summarize_review(review):
13
+ if not review.strip():
14
+ return "Please enter a review."
15
+ output = summarizer(review, max_length=60, min_length=10, do_sample=False)
16
+ return output[0]["summary_text"]
17
+
18
+ examples = [
19
+ ["This is the worst coffee maker I’ve ever used. It leaks water everywhere, the buttons barely work, and the brew tastes like plastic."],
20
+ ["Great product! Easy to use, super fast delivery, and the quality is outstanding. Highly recommend!"],
21
+ ["Battery life is average but display quality and sound are top-notch."],
22
+ ["Not worth the money. Poor customer service and the build feels cheap."]
23
+ ]
24
+
25
+ demo = gr.Interface(
26
+ fn=summarize_review,
27
+ inputs=gr.Textbox(lines=6, placeholder="Paste a product review here..."),
28
+ outputs="text",
29
+ examples=examples,
30
+ title="Review Summariser GPT",
31
+ description="Enter a product review to get a helpful summary using Config1 fine-tuned T5-small model."
32
+ )
33
+
34
+ demo.launch()