DEV Community

Mantresh Khurana
Mantresh Khurana

Posted on

Building a Flask-Based Twitter Toxicity Detection App

Introduction

Welcome to the Twitter Toxicity Detection Flask App repository! If you’re interested in understanding and analyzing online conversations for toxicity, this project is a perfect starting point. Leveraging the power of machine learning and natural language processing (NLP), the app detects toxic tweets and serves as a template for real-world toxicity analysis tools.

🚀 Key Features 1. User-Friendly Flask Web Interface: • A simple and clean Flask-based web app. • Easy-to-use form to input tweets for toxicity analysis. 2. Advanced Machine Learning Model: • Utilizes pretrained NLP models to assess toxicity in text. • Capable of detecting toxic, abusive, or harmful language. 3. Real-Time Results: • Processes and provides toxicity insights almost instantly. • Includes detailed breakdowns of toxic categories like hate speech, profanity, and more.

🛠️ Installation & Setup

Clone the Repository

git clone https://github.com/mantreshkhurana/twitter-toxicity-detection-flask.git cd twitter-toxicity-detection-flask

Install Dependencies

Use pip to install the required Python libraries:

pip install -r requirements.txt

Set Up Environment Variables

Create a .env file in the root directory and set your API keys or other sensitive configurations:

API_KEY=your_api_key_here MODEL_PATH=path_to_pretrained_model

Run the App

Start the Flask server with:

python app.py

Navigate to http://127.0.0.1:5000/ in your browser to access the web interface.

🌟 How It Works 1. Input: Users input a tweet or text. 2. Model Processing: The text is sent to the backend, where the machine learning model predicts its toxicity level. 3. Output: Results are displayed on the web page, showing toxicity percentages and categories.

📁 Project Structure

twitter-toxicity-detection-flask/ │ ├── app.py # Flask application entry point ├── templates/ # HTML templates for the app ├── static/ # Static files (CSS, JS, images) ├── models/ # Directory for pretrained models ├── requirements.txt # Python dependencies └── README.md # Project documentation

✨ Highlights

Flask Integration

The app is built on Flask, providing a lightweight yet powerful web interface for user interaction. It serves as an excellent demonstration of integrating machine learning models with web frameworks.

Pretrained Models

By leveraging pretrained NLP models, the app avoids the complexity of training models from scratch. This ensures quick deployment and efficient analysis.

🤝 Contributions

Contributions are welcome! To contribute: 1. Fork the repository. 2. Create a new branch for your feature. 3. Submit a pull request.

🛡️ License

This project is licensed under the MIT License. Feel free to use, modify, and distribute this repository in your own projects.

📧 Connect with Me

If you have questions, suggestions, or ideas, feel free to reach out:

Check out the repository and start your journey into toxicity detection today! 🚀

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay