Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
@@ -1,34 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
|
4 |
-
|
5 |
-
model_name = "Manish014/review-summariser-gpt-config1"
|
6 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
-
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
# Define Gradio UI
|
12 |
-
def summarize_review(review):
|
13 |
-
if not review.strip():
|
14 |
return "Please enter a review."
|
15 |
-
|
16 |
-
return output[0]["summary_text"]
|
17 |
|
18 |
-
|
19 |
-
["This
|
20 |
-
["
|
21 |
-
["
|
22 |
-
["Not worth the money. Poor customer service and the build feels cheap."]
|
23 |
]
|
24 |
|
25 |
demo = gr.Interface(
|
26 |
-
fn=
|
27 |
-
inputs=gr.Textbox(lines=
|
28 |
-
outputs="
|
29 |
-
examples=
|
30 |
-
title="Review Summariser GPT",
|
31 |
-
description="Enter a product review
|
32 |
)
|
33 |
|
34 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
pipe = pipeline("summarization", model="Manish014/review-summariser-gpt-config1")
|
|
|
|
|
|
|
5 |
|
6 |
+
def summarize(text):
|
7 |
+
if not text.strip():
|
|
|
|
|
|
|
8 |
return "Please enter a review."
|
9 |
+
return pipe(text)[0]["summary_text"]
|
|
|
10 |
|
11 |
+
example_reviews = [
|
12 |
+
["This product leaks water and smells like burnt plastic."],
|
13 |
+
["Absolutely loved the screen resolution and battery life."],
|
14 |
+
["Worst purchase I've made. Do not recommend at all."]
|
|
|
15 |
]
|
16 |
|
17 |
demo = gr.Interface(
|
18 |
+
fn=summarize,
|
19 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter product review..."),
|
20 |
+
outputs=gr.Textbox(label="Summary"),
|
21 |
+
examples=example_reviews,
|
22 |
+
title="Review Summariser GPT - Config 1",
|
23 |
+
description="Enter a long product review and get a helpful short summary."
|
24 |
)
|
25 |
|
26 |
demo.launch()
|