Spaces:
Sleeping
Sleeping
File size: 3,418 Bytes
52d3bfa 4800f54 5f16a0d 4800f54 52d3bfa 5f16a0d 52d3bfa 4800f54 e965d9c 4800f54 | 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | ---
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
```text
.
|-- app.py
|-- index.html
|-- requirements.txt
|-- Dockerfile
|-- README.md
`-- saved_summary_model/
```
## Tech Stack
- FastAPI
- Uvicorn
- Hugging Face Transformers
- PyTorch
- Jinja2
## How It Works
1. The user enters text in the web interface.
2. The frontend sends the text to the `/summarize` API endpoint.
3. The backend cleans the input text.
4. The fine-tuned T5 model generates a summary.
5. The summary is returned and displayed in the browser.
## API Endpoint
### `POST /summarize`
Request body:
```json
{
"dialogue": "Enter the text you want to summarize here."
}
```
Response:
```json
{
"summary": "Generated summary text."
}
```
## Run Locally
### 1. Clone the repository
```bash
git clone <your-repository-url>
cd "Text Summarizer Web App"
```
### 2. Install dependencies
```bash
pip install -r requirements.txt
```
### 3. Make sure the model folder exists
The app loads the model from:
```text
saved_summary_model/
```
This folder must contain the fine-tuned model and tokenizer files.
### 4. Start the app
```bash
uvicorn app:app --reload
```
### 5. Open in browser
```text
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.py`
- `index.html`
- `requirements.txt`
- `Dockerfile`
- `README.md`
- `saved_summary_model/`
### Deployment steps
1. Create a new Space on Hugging Face.
2. Choose `Docker` as the Space SDK.
3. Upload or push the project files to the Space repository.
4. Wait for Hugging Face to build the Docker image.
5. 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:
```bash
uvicorn app:app --host 0.0.0.0 --port 7860
```
## Notes
- `render.yaml` is 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
|