A simple web application built with FastAPI and Hugging Face Transformers that uses the T5 model to generate concise summaries from dialogue or long text.
- Data Training Pipeline: Includes a Jupyter Notebook for data preprocessing and model training.
- T5-based Summarization: Uses a fine-tuned T5 model for high-quality text compression.
- FastAPI Backend: High-performance asynchronous API.
- Jinja2 Templates: Simple HTML interface for easy interaction.
- Hardware Acceleration: Automatically detects and uses CUDA (NVIDIA) or MPS (Apple Silicon) if available, falling back to CPU.
graph TD
A[CSV Data] --> B[Notebook: Preprocessing]
B --> C[Notebook: Model Training]
C --> D[Saved Model Artifacts]
D --> E[FastAPI /summarize Endpoint]
E --> F[Data Cleaning / Regex]
F --> G[T5 Tokenization]
G --> H[Model Inference]
H --> I[Return Summary JSON]
.
├── app.py # FastAPI application logic
├── index.html # Frontend UI
├── text_summarizer.ipynb # Data preprocessing & training pipeline
├── data/ # Source .csv datasets for training
├── saved_summary_model/ # Local T5 model weights and tokenizer (output of notebook)
└── venv/ # Python virtual environment
-
Clone the repository:
git clone github.com/imHardik1606/T5-Text-Summarizer cd "Summarizer App"
-
Create and activate a virtual environment:
python -m venv venv .\venv\Scripts\Activate.ps1 -
Install dependencies:
pip install fastapi uvicorn transformers torch jinja2 sentencepiece
-
Add your model: Place your fine-tuned T5 model files inside the
saved_summary_model/folder.
Start the server using uvicorn:
uvicorn app:app --reloadOpen your browser and navigate to http://127.0.0.1:8000.
GET /: Serves the web-based UI.POST /summarize: Accepts a JSON body{"dialogue": "your text here"}and returns a summary.
MIT