AI Text Summarizer: Ek Smart Tool Jo Badi Text Ko Short Mein Convert Kare!

Demo :


Click Video πŸ‘‡πŸ‘‡πŸ‘‡











Features:

  • AI-Powered Summarization
  • Instant Results
  • Simple & Fast

πŸ“ Folder Structure:

πŸ“ AI_Text_Summarizer/
│── πŸ“„ app.py
│── πŸ“„ requirements.txt
│── πŸ“‚ templates/
│   ├── πŸ“„ index.html
│── πŸ“‚ static/
│   ├── πŸ“„ style.css


Install Required Libraries

cmd : pip install flask transformers torch


Code :

Python Backend (app.py)

from flask import Flask, render_template, request
import torch
from transformers import pipeline

app = Flask(__name__)

# Check if PyTorch is available
if not torch.cuda.is_available():
    print("Warning: CUDA (GPU) not available, using CPU.")

# Load Pre-Trained Summarization Model
try:
    summarizer = pipeline("summarization", device=0 if torch.cuda.is_available() else -1)
except Exception as e:
    print(f"Error loading model: {e}")
    summarizer = None  # Model load failure handling

@app.route("/", methods=["GET", "POST"])
def index():
    summary = ""
    if request.method == "POST":
        input_text = request.form["input_text"]
        if input_text and summarizer:
            try:
                summary = summarizer(input_text, max_length=150, min_length=30, do_sample=False)[0]['summary_text']
            except Exception as e:
                summary = f"Error summarizing text: {e}"
    return render_template("index.html", summary=summary)

if __name__ == "__main__":
    app.run(debug=True)


HTML Frontend (templates/index.html)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Text Summarizer</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
    <h2>AI-Powered Text Summarizer</h2>
    <form method="post">
        <textarea name="input_text" rows="5" placeholder="Yahan text paste karo..."></textarea>
        <button type="submit">Summarize</button>
    </form>
    {% if summary %}
        <h3>Summary:</h3>
        <p>{{ summary }}</p>
    {% endif %}
</body>
</html>


 CSS Styling (static/style.css)


body {

    font-family: Arial, sans-serif;

    text-align: center;

    padding: 20px;

    background-color: #f4f4f4;

}

textarea {

    width: 80%;

    padding: 10px;

    margin: 10px;

}

button {

    padding: 10px 20px;

    background-color: #007BFF;

    color: white;

    border: none;

    cursor: pointer;

}



🎯 Run The Code : 

python app.py


Comments

Popular posts from this blog

Is This News Real or Fake? πŸ€– AI Exposes the Truth | FuzzuTech Python App Demo

🚨 Python Intrusion Detection System (IDS) – Real-Time ML + Tkinter GUI Project | FuzzuTech

πŸš€ Simple Login & Registration System in Python Tkinter πŸ“±