ar08 commited on
Commit
b80349f
·
verified ·
1 Parent(s): 7851533

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Load the summarizer model
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
+
7
+ # Define the function for Gradio to use
8
+ def summarize_article(text):
9
+ summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
10
+ return summary[0]['summary_text']
11
+
12
+ # Gradio interface
13
+ iface = gr.Interface(
14
+ fn=summarize_article,
15
+ inputs=gr.Textbox(lines=20, label="Enter News Article 📄"),
16
+ outputs=gr.Textbox(label="Summary ✨"),
17
+ title="Article Summarizer 📰",
18
+ description="Paste your article and get a short summary! Powered by facebook/bart-large-cnn."
19
+ )
20
+
21
+ # Launch the app
22
+ iface.launch()