tejovanth commited on
Commit
d838df2
·
verified ·
1 Parent(s): 7b5ae2d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load summarization pipeline
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
6
+
7
+ # Define function to summarize input text
8
+ def summarize_notes(text):
9
+ if len(text.strip()) == 0:
10
+ return "Please paste your academic notes."
11
+ summary = summarizer(text, max_length=150, min_length=40, do_sample=False)
12
+ return summary[0]['summary_text']
13
+
14
+ # Gradio interface
15
+ demo = gr.Interface(
16
+ fn=summarize_notes,
17
+ inputs=gr.Textbox(lines=15, placeholder="Paste your academic notes here...", label="Academic Notes"),
18
+ outputs=gr.Textbox(label="Summarized Notes"),
19
+ title="📚 Academic Note Summarizer",
20
+ description="Paste your long academic notes and get a short summary using a Hugging Face Transformer model."
21
+ )
22
+
23
+ # Launch the app
24
+ demo.launch()