Spaces:
Sleeping
Sleeping
File size: 861 Bytes
8674b9e ca5e899 8674b9e 01936d5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import gradio as gr
from transformers import pipeline
import fitz # PyMuPDF for PDF reading
# Summarizer model
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
def summarize_pdf(pdf_file):
if pdf_file is None:
return "Please upload a PDF file."
# Reading PDF
doc = fitz.open(pdf_file.name)
text = ""
for page in doc:
text += page.get_text()
if len(text) < 100:
return "PDF me enough text nahi mila."
# Summarization
summary = summarizer(text, max_length=200, min_length=50, do_sample=False)
return summary[0]["summary_text"]
# Gradio UI
interface = gr.Interface(
fn=summarize_pdf,
inputs=gr.File(label="Upload PDF here"),
outputs="text",
title="AI PDF Notes & Summary Maker",
description="Upload any PDF and get instant summary."
)
interface.launch() |