Rekham1110 commited on
Commit
79b51ce
·
verified ·
1 Parent(s): 120832a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the Hugging Face pre-trained summarization model
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
+
7
+ # Define the function for text summarization
8
+ def summarize_text(input_text):
9
+ # Get the summary from the model
10
+ summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False)
11
+ return summary[0]['summary_text']
12
+
13
+ # Create the Gradio interface
14
+ interface = gr.Interface(fn=summarize_text, inputs="text", outputs="text", title="Text Summarization App")
15
+
16
+ # Launch the app
17
+ interface.launch()