exampletwo / app.py
tejovanth's picture
Create app.py
d838df2 verified
raw
history blame
837 Bytes
import gradio as gr
from transformers import pipeline
# Load summarization pipeline
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
# Define function to summarize input text
def summarize_notes(text):
if len(text.strip()) == 0:
return "Please paste your academic notes."
summary = summarizer(text, max_length=150, min_length=40, do_sample=False)
return summary[0]['summary_text']
# Gradio interface
demo = gr.Interface(
fn=summarize_notes,
inputs=gr.Textbox(lines=15, placeholder="Paste your academic notes here...", label="Academic Notes"),
outputs=gr.Textbox(label="Summarized Notes"),
title="📚 Academic Note Summarizer",
description="Paste your long academic notes and get a short summary using a Hugging Face Transformer model."
)
# Launch the app
demo.launch()