Skip to content

Repository files navigation

title SummaPDF
emoji 📄
colorFrom purple
colorTo blue
sdk docker
app_port 7860
pinned false

PDF Summarizer

A web app that summarizes PDF documents using Hugging Face's BART-large-CNN model.

Tech stack

  • FastAPI — async Python web framework
  • HTMX — interactivity without writing JavaScript
  • Tailwind CSS — utility-first styling (via CDN)
  • Jinja2 — server-rendered templates
  • pypdf — PDF text extraction
  • transformers + PyTorch — running facebook/bart-large-cnn locally

Features

  • Drag-and-drop PDF upload with file preview (name + size)
  • Length presets (Brief / Balanced / Detailed) plus a manual min/max under "Advanced"
  • Chunked summarization for long documents
  • Result card with stats: source characters, summary words, compression %
  • Copy-to-clipboard and .txt download
  • Inline error reporting and a button-embedded loading state, all via HTMX
  • Dark UI with gradient mesh background, Inter typography, subtle animations

Installation

git clone https://github.com/shexiee/summapdf.git
cd summapdf
pip install -r requirements.txt

The first run downloads the BART model (~1.6 GB) into the Hugging Face cache.

Running locally

uvicorn main:app --reload

Open http://localhost:8000.

Project layout

.
├── main.py                       # FastAPI app + summarization logic
├── templates/
│   ├── base.html                 # HTML shell (Tailwind + HTMX)
│   ├── index.html                # Upload form
│   └── partials/
│       ├── summary.html          # HTMX swap target on success
│       └── error.html            # HTMX swap target on failure
├── static/                       # Optional static assets
└── requirements.txt

How it works

  1. The form POSTs a PDF to /summarize via HTMX (multipart/form-data).
  2. pypdf extracts the document text.
  3. The text is sliced into 1024-character chunks (BART's input limit).
  4. Each chunk is summarized; the summaries are concatenated.
  5. The server returns an HTML partial, which HTMX swaps into the page — no full reload.

Deployment

Any host that runs Python works (Render, Railway, Fly.io, a VPS). Example start command:

uvicorn main:app --host 0.0.0.0 --port $PORT

Note: the Tailwind CDN logs a console warning in production. For a polished deploy, swap it for a compiled stylesheet (npx tailwindcss -i input.css -o static/app.css --minify) and serve from /static.

Requirements

  • Python 3.9+
  • ~2 GB free disk for the model cache
  • CPU works; a GPU dramatically speeds up summarization

About

PDF summarizer tool using BART huggingface API

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages