Spaces:
Sleeping
Sleeping
metadata
title: Text Summarizer FastAPI
emoji: 📝
colorFrom: yellow
colorTo: yellow
sdk: docker
pinned: false
license: mit
short_description: FastAPI app for text summarization with a T5 model.
Text Summarizer Web App
A text summarization web application built with FastAPI, Transformers, and a fine-tuned T5 model. The app provides a simple browser interface where users can paste text and get a concise summary.
This project is configured for deployment on Hugging Face Spaces using Docker.
Live Demo
- Space page:
https://huggingface.co/spaces/Arpit16112/Text_Summarizer_FastAPI - Public app URL:
https://arpit16112-text-summarizer-fastapi.hf.space
Demo Screenshots
Home Page
Summary Result
Features
- Summarizes long text into a shorter version using a fine-tuned T5 model
- Simple web interface built with HTML, CSS, and JavaScript
- FastAPI backend with a JSON API endpoint
- Ready for Hugging Face Spaces deployment
- Can also be run locally with
uvicorn
Project Structure
.
|-- app.py
|-- index.html
|-- requirements.txt
|-- Dockerfile
|-- README.md
`-- saved_summary_model/
Tech Stack
- FastAPI
- Uvicorn
- Hugging Face Transformers
- PyTorch
- Jinja2
How It Works
- The user enters text in the web interface.
- The frontend sends the text to the
/summarizeAPI endpoint. - The backend cleans the input text.
- The fine-tuned T5 model generates a summary.
- The summary is returned and displayed in the browser.
API Endpoint
POST /summarize
Request body:
{
"dialogue": "Enter the text you want to summarize here."
}
Response:
{
"summary": "Generated summary text."
}
Run Locally
1. Clone the repository
git clone <your-repository-url>
cd "Text Summarizer Web App"
2. Install dependencies
pip install -r requirements.txt
3. Make sure the model folder exists
The app loads the model from:
saved_summary_model/
This folder must contain the fine-tuned model and tokenizer files.
4. Start the app
uvicorn app:app --reload
5. Open in browser
http://127.0.0.1:8000
Deploy on Hugging Face Spaces
This project uses a Docker-based Hugging Face Space.
Required files for deployment
app.pyindex.htmlrequirements.txtDockerfileREADME.mdsaved_summary_model/
Deployment steps
- Create a new Space on Hugging Face.
- Choose
Dockeras the Space SDK. - Upload or push the project files to the Space repository.
- Wait for Hugging Face to build the Docker image.
- Open the deployed Space once the build completes.
Docker Notes
The app runs on port 7860 inside the container, which matches Hugging Face Spaces requirements.
The Docker container starts the app with:
uvicorn app:app --host 0.0.0.0 --port 7860
Notes
render.yamlis not needed for Hugging Face deployment.__pycache__/is not needed for deployment.- If you move CSS or JavaScript into separate files, make sure they are properly linked from
index.html.
Future Improvements
- Add input validation and better error messages
- Add loading indicators and improved UI feedback
- Move inline CSS and JavaScript into separate static files
- Add example input text
- Add automated tests

