The Text Summarizer project is a Django-based web application that leverages AI to generate concise summaries of long texts. It uses the Facebook BART model for high-quality text summarization, ensuring that key information is preserved while reducing the overall length of the input text.
- Web Interface: A user-friendly interface to input text and view summaries.
- AI-Powered Summarization: Utilizes the
transformerslibrary and the BART model for accurate and efficient text summarization. - API Support: Provides an API endpoint for programmatic access to the summarization functionality.
- Customizable Model: Includes a pre-trained model that can be fine-tuned or replaced with other summarization models.
-
Clone the repository:
git clone <repository-url> cd text-summarizer
-
Set up a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Apply migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
-
Access the application at
http://127.0.0.1:8000/.
- Navigate to the home page.
- Paste your text into the input box.
- Click "Generate Summary" to view the summarized text.
- Endpoint:
/api/summarize/ - Method: POST
- Payload:
{ "text": "Your text here" } - Response:
{ "summary": "Summarized text" }
- Using Curl
curl -X POST "http://localhost:8000/api/v1/summarize/" \
-H "Content-Type: application/json" \
-d '{
"text": "Your long text here...",
"max_length": 150,
"min_length": 40
}'
- Using javascript(fetch Api)
const summarizeText = async (text) => {
const response = await fetch('/api/v1/summarize/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: text,
max_length: 150,
min_length: 40
})
});
return await response.json();
};
// Usage
summarizeText("Your long article text...")
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
- Using Python requests library
import requests
api_url = "http://localhost:8000/api/v1/summarize/"
data = {
"text": "Your long text here...",
"max_length": 150,
"min_length": 40
}
response = requests.post(api_url, json=data)
print(response.json())
- Check Api status
curl http://localhost:8000/api/v1/status/
summarizer/: Contains Django project settings and configurations.text/: Main app for text summarization, including views, templates, and services.my_summarizer_model/: Directory for the pre-trained summarization model.templates/: HTML templates for the web interface.
The project uses the facebook/bart-large-cnn model from Hugging Face's Transformers library. The model is downloaded and saved locally for efficient reuse.
This project is licensed under the MIT License.