|
|
--- |
|
|
title: DetectAI |
|
|
emoji: π΅οΈ |
|
|
colorFrom: gray |
|
|
colorTo: blue |
|
|
sdk: docker |
|
|
|
|
|
pinned: false |
|
|
--- |
|
|
|
|
|
# DetectAI |
|
|
 |
|
|
|
|
|
A local, offline AI text detection tool powered by **RoBERTa** and **GPU Acceleration**. |
|
|
|
|
|
## π Features |
|
|
- **Offline Analysis:** Uses a local Transformer model (`roberta-base`) to detect AI-generated text. |
|
|
- **GPU Accelerated:** Optimized for NVIDIA GPUs (CUDA 12.1) for <1s inference. |
|
|
- **Visual Reports:** Downloadable PDF reports with AI-highlighted text. |
|
|
- **Modern UI:** Built with React + Vite, featuring a glassmorphism design. |
|
|
|
|
|
## π οΈ Tech Stack |
|
|
- **Backend:** Python, Django, Django Rest Framework |
|
|
- **AI Engine:** PyTorch, Transformers (Hugging Face) |
|
|
- **Frontend:** React, TailwindCSS, Framer Motion |
|
|
- **PDF Generation:** ReportLab |
|
|
|
|
|
## π¦ Installation |
|
|
|
|
|
### Prerequisites |
|
|
1. **Python 3.10+** |
|
|
2. **Node.js & npm** |
|
|
3. **NVIDIA GPU Driver** (Version >= 531.x for CUDA 12.1 support) |
|
|
|
|
|
### 1. Backend Setup |
|
|
```bash |
|
|
cd backend |
|
|
python -m venv venv |
|
|
# Activate venv: |
|
|
# Windows: .\venv\Scripts\activate |
|
|
# Linux/Mac: source venv/bin/activate |
|
|
|
|
|
# Install Dependencies (includes PyTorch CUDA) |
|
|
pip install -r requirements.txt |
|
|
# OR manually: |
|
|
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 |
|
|
pip install django djangorestframework transformers reportlab |
|
|
``` |
|
|
|
|
|
### 2. Frontend Setup |
|
|
```bash |
|
|
cd frontend |
|
|
npm install |
|
|
``` |
|
|
|
|
|
## πββοΈ Running the App |
|
|
|
|
|
### Step 1: Start Backend (Port 8000) |
|
|
```bash |
|
|
cd backend |
|
|
python manage.py runserver |
|
|
``` |
|
|
|
|
|
### Step 2: Start Frontend (Port 5173) |
|
|
```bash |
|
|
cd frontend |
|
|
npm run dev |
|
|
``` |
|
|
|
|
|
### Step 3: Open App |
|
|
Go to **[http://localhost:5173](http://localhost:5173)** in your browser. |
|
|
|
|
|
## β‘ Performance Tuning |
|
|
The backend is pre-optimized for 4GB VRAM cards (like GTX 1650): |
|
|
- **Batch Size:** 8 |
|
|
- **Strided Masking:** Analyzes 33% of tokens for 3x speedup. |
|
|
To change these, edit `backend/detector/views.py`. |
|
|
|
|
|
## π Deployment (Hugging Face Spaces) |
|
|
|
|
|
This project relies on **Docker** and **GitHub Actions** for deployment. |
|
|
|
|
|
### 1. Prerequisites |
|
|
- A **Hugging Face Account**. |
|
|
- A **Private Space** created on Hugging Face (Select "Docker" as the SDK). |
|
|
|
|
|
### 2. Configure GitHub Secrets |
|
|
Go to your GitHub Repository -> **Settings** -> **Secrets and variables** -> **Actions** -> **New repository secret**. |
|
|
|
|
|
Add the following secrets: |
|
|
| Secret Name | Value | |
|
|
| :--- | :--- | |
|
|
| `HF_TOKEN` | Your Hugging Face Access Token (Write permissions). | |
|
|
| `HF_USERNAME` | Your Hugging Face Username (e.g., `vivek1192`). | |
|
|
|
|
|
### 3. Trigger Deployment |
|
|
1. **Commit your changes:** |
|
|
```bash |
|
|
git add . |
|
|
git commit -m "Setup CI/CD for Hugging Face" |
|
|
``` |
|
|
2. **Push to `develop` branch:** |
|
|
(The workflow is configured to trigger on `develop`) |
|
|
```bash |
|
|
git checkout develop |
|
|
# Merge your changes if needed |
|
|
git push origin develop |
|
|
``` |
|
|
|
|
|
The GitHub Action will: |
|
|
1. Build the Docker image (React Frontend + Django Backend). |
|
|
2. Push it to your Hugging Face Space. |
|
|
|