Spaces:
Sleeping
Sleeping
| 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 | |