--- title: Text Pdf Summarizer Ui emoji: 🐠 colorFrom: blue colorTo: gray sdk: gradio sdk_version: 5.29.0 app_file: app.py pinned: false license: mit short_description: πŸ“ Text & PDF Summarizer UI --- # πŸ“ Text & PDF Summarizer UI A lightweight web application that allows users to paste text or upload a PDF document, then summarizes the content using a HuggingFace transformer model integrated with LangChain and displayed via a Gradio interface. ## πŸš€ Key Features - Input text manually or via PDF upload - Extracts and summarizes PDF text using NLP - User-friendly Gradio interface - Uses pre-trained `facebook/bart-large-cnn` summarization model ## πŸ—οΈ Project Architecture - **Gradio**: Frontend interface to interact with the app - **PyPDF2**: Extracts text from PDF files - **LangChain**: Framework for managing LLM-based workflows - **HuggingFace**: Provides transformer models like BART for summarization ## πŸ”§ Getting Started **1- Clone the repo** ```bash git clone https://github.com/rahimizadeh/text-pdf-summarizer-ui.git cd text-pdf-summarizer-ui ```    πŸ“**Project Structure**       β”œβ”€β”€ text-pdf-summarizer-ui/             β”œβ”€β”€ app.py    # Application             β””── requirements.txt             β””── README.md **2- Create a virtual environment (optional)** ``` python -m venv venv source venv/bin/activate # On Windows: venv\\Scripts\\activate ``` **3- Install dependencies** ```bash pip install -r requirements.txt ``` **4- Run the app** ```bash python app.py ``` ## 🧠 About the Tools  **LangChain**: provides a modular framework for building applications with language models. Here, it's used to manage prompting and model output formatting.  **HuggingFace Transformers**: We use the facebook/bart-large-cnn model, a powerful encoder-decoder model ideal for summarization.  **Gradio**: lets us quickly build and share user-friendly web interfaces for Machine Learning apps. ## πŸ” Implementation Details    1- Model Initialization: Using HuggingFacePipeline via LangChain    2- PromptTemplate: Wraps text for inference    3- PDF Handling: Reads uploaded file as bytes and extracts text using PyPDF2    4- UI Logic: Built with Gradio Blocks to control layout, input, and output ## βœ… Example Usage - Upload a PDF or paste article text - Cick β€œConvert PDF to Text” (if PDF)- - Click β€œSummarize Text” - View summary below the input ## πŸ“ License MIT ## 🀝 Contributions Pull requests and suggestions welcome! Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference