MrSimple07 commited on
Commit
f3b811a
·
verified ·
1 Parent(s): 8d1dcf9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the BART summarization model from Hugging Face
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
+
7
+ # Define the function that will summarize the text
8
+ def summarize_text(input_text):
9
+ summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False)
10
+ return summary[0]['summary_text']
11
+
12
+ # Create a Gradio interface
13
+ iface = gr.Interface(fn=summarize_text,
14
+ inputs="text",
15
+ outputs="text",
16
+ title="Text Summarization App",
17
+ description="This app summarizes long-form text (articles, papers, books) into concise key points or a paragraph.",
18
+ examples=[["Enter your article text here"]])
19
+
20
+ # Launch the interface
21
+ iface.launch()