File size: 5,504 Bytes
183f1c4
6396e6b
 
 
 
 
 
 
 
1e91f18
 
47c1352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d3b6b2e
72449a3
1e91f18
d3b6b2e
1e91f18
d3b6b2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1e91f18
6396e6b
d3b6b2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47c1352
 
 
 
 
d3b6b2e
 
 
 
 
 
 
273204e
 
 
d3b6b2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a71624
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
---
title: Testing AI Contain
emoji: πŸ€–
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: "latest"
app_file: app.py
pinned: false
---

# Testing AI Contain

This Hugging Face Space uses **Docker** to run a custom environment for AI content detection.

## How to run locally
---
title: Testing AI Contain
emoji: πŸ€–
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: "latest"
app_file: app.py
pinned: false
---

# AI-Contain-Checker
# AI-Content-Checker

A modular AI content detection system with support for **image classification**, **image edit detection**, **Nepali text classification**, and **general text classification**. Built for performance and extensibility, it is ideal for detecting AI-generated content in both visual and textual forms.


## 🌟 Features

### πŸ–ΌοΈ Image Classifier

* **Purpose**: Classifies whether an image is AI-generated or a real-life photo.
* **Model**: Fine-tuned **InceptionV3** CNN.
* **Dataset**: Custom curated dataset with **\~79,950 images** for binary classification.
* **Location**: [`features/image_classifier`](features/image_classifier)
* **Docs**: [`docs/features/image_classifier.md`](docs/features/image_classifier.md)

### πŸ–ŒοΈ Image Edit Detector

* **Purpose**: Detects image tampering or post-processing.
* **Techniques Used**:

  * **Error Level Analysis (ELA)**: Visualizes compression artifacts.
  * **Fast Fourier Transform (FFT)**: Detects unnatural frequency patterns.
* **Location**: [`features/image_edit_detector`](features/image_edit_detector)
* **Docs**:

  * [ELA](docs/detector/ELA.md)
  * [FFT](docs/detector/fft.md )
  * [Metadata Analysis](docs/detector/meta.md)
  * [Backend Notes](docs/detector/note-for-backend.md)

### πŸ“ Nepali Text Classifier

* **Purpose**: Determines if Nepali text content is AI-generated or written by a human.
* **Model**: Based on `XLMRClassifier` fine-tuned on Nepali language data.
* **Dataset**: Scraped dataset of **\~18,000** Nepali texts.
* **Location**: [`features/nepali_text_classifier`](features/nepali_text_classifier)
* **Docs**: [`docs/features/nepali_text_classifier.md`](docs/features/nepali_text_classifier.md)

### 🌐 English Text Classifier

* **Purpose**: Detects if English text is AI-generated or human-written.
* **Pipeline**:

  * Uses **GPT2 tokenizer** for input preprocessing.
  * Custom binary classifier to differentiate between AI and human-written content.
* **Location**: [`features/text_classifier`](features/text_classifier)
* **Docs**: [`docs/features/text_classifier.md`](docs/features/text_classifier.md)

---

## πŸ—‚οΈ Project Structure

```bash
AI-Checker/
β”‚
β”œβ”€β”€ app.py                  # Main FastAPI entry point
β”œβ”€β”€ config.py               # Configuration settings
β”œβ”€β”€ Dockerfile              # Docker build script
β”œβ”€β”€ Procfile                # Deployment file for Heroku or similar
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ README.md               # You are here πŸ“˜
β”‚
β”œβ”€β”€ features/               # Core detection modules
β”‚   β”œβ”€β”€ image_classifier/
β”‚   β”œβ”€β”€ image_edit_detector/
β”‚   β”œβ”€β”€ nepali_text_classifier/
β”‚   └── text_classifier/
β”‚
β”œβ”€β”€ docs/                   # Internal and API documentation
β”‚   β”œβ”€β”€ api_endpoints.md
β”‚   β”œβ”€β”€ deployment.md
β”‚   β”œβ”€β”€ detector/
β”‚   β”‚   β”œβ”€β”€ ELA.md
β”‚   β”‚   β”œβ”€β”€ fft.md
β”‚   β”‚   β”œβ”€β”€ meta.md
β”‚   β”‚   └── note-for-backend.md
β”‚   β”œβ”€β”€ functions.md
β”‚   β”œβ”€β”€ nestjs_integration.md
β”‚   β”œβ”€β”€ security.md
β”‚   β”œβ”€β”€ setup.md
β”‚   └── structure.md
β”‚
β”œβ”€β”€ IMG_Models/             # Saved image classifier model(s)
β”‚   └── latest-my_cnn_model.h5
β”‚
β”œβ”€β”€ notebooks/              # Experimental and debug notebooks
β”œβ”€β”€ static/                 # Static assets if needed
└── test.md                 # Test notes
````

---

## πŸ“š Documentation Links

* [API Endpoints](docs/api_endpoints.md)
* [Deployment Guide](docs/deployment.md)
* [Detector Documentation](docs/detector/)

  * [Error Level Analysis (ELA)](docs/detector/ELA.md)
  * [Fast Fourier Transform (FFT)](docs/detector/fft.md)
  * [Metadata Analysis](docs/detector/meta.md)
  * [Backend Notes](docs/detector/note-for-backend.md)
* [Functions Overview](docs/functions.md)
* [NestJS Integration Guide](docs/nestjs_integration.md)
* [Security Details](docs/security.md)
* [Setup Instructions](docs/setup.md)
* [Project Structure](docs/structure.md)

---

## πŸš€ Usage

1. **Install dependencies**

```bash
docker build -t testing-ai-contain .
docker run -p 7860:7860 testing-ai-contain

```
   ```bash
   pip install -r requirements.txt
   ```

2. **Run the API**

   ```bash
   chroma run --path ./chroma_database ## to run chromadb locally
   uvicorn app:app --reload --port 8001 ## fastapi (run after chromadb)

   ```

3. **Build Docker (optional)**

   ```bash
   docker build -t ai-contain-checker .
   docker run -p 8000:8000 ai-contain-checker
   ```

---

## πŸ” Security & Integration

* **Token Authentication** and **IP Whitelisting** supported.
* NestJS integration guide: [`docs/nestjs_integration.md`](docs/nestjs_integration.md)
* Rate limiting handled using `slowapi`.

---

## πŸ›‘οΈ Future Plans

* Add **video classifier** module.
* Expand dataset for **multilingual** AI content detection.
* Add **fine-tuning UI** for models.

---

## πŸ“„ License

See full license terms here: [`LICENSE.md`](license.md)