File size: 3,068 Bytes
97684bb
 
 
 
 
 
7c19daf
97684bb
 
 
171eb01
447a8f0
35577cb
171eb01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: DetectAI
emoji: ๐Ÿ•ต๏ธ
colorFrom: gray
colorTo: blue
sdk: docker

pinned: false
---

# DetectAI
![Deploy to Hugging Face Space](https://github.com/vivek1192/detectAI/actions/workflows/deploy.yml/badge.svg)

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.