# Amharic Hate Speech Detector
This application is designed to detect hate speech in Amharic text. It uses a fine-tuned BERT-based model to classify input text into two categories: "Hate Speech" or "Free Speech." The model is loaded dynamically from Hugging Face, and the application is implemented using FastAPI for efficient and scalable API services.
## Features
- **Dynamic Model Loading**: The model can be dynamically selected by specifying its name in an environment variable.
- **RESTful API Endpoint**: The application provides a single endpoint (`/predict`) to classify text.
- **Customizable Labels**: Outputs are mapped to human-readable labels (`free` and `hate`).
- **Web-Based Interface**: Includes a simple HTML template to interact with the API and test the model.
## Getting Started
### Prerequisites
Ensure the following are installed on your system:
- Python 3.8 or later
- pip (Python package manager)
- `virtualenv` (optional, but recommended)
### Installation
1. Clone the repository:
```bash
git clone
github.com
cd amharic-hate-speech-detector
```
2. Create a virtual environment (optional):
```bash
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Set up environment variables:
- Create a `.env` file in the root directory:
```env
MODEL_NAME=amharic-hate-speech-detection-mBERT
```
- Replace `amharic-hate-speech-detection-mBERT` with your preferred model name on Hugging Face if needed.
## Usage
### Running the Application
1. Start the FastAPI application:
```bash
uvicorn main:app --reload
```
2. Open your browser and visit:
- API Docs:
127.0.0.1
- Web Interface: Open `index.html` in a browser (manually or host it using a simple HTTP server).
### API Endpoints
#### **POST** `/predict`
Predicts whether the given Amharic text is hate speech or free speech.
- ** …