File size: 2,787 Bytes
023f8b8
b1a7d13
023f8b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c4cf68
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
---
title: TextTector - AI Text Detector
emoji: 🤖
colorFrom: indigo
colorTo: blue
sdk: streamlit
sdk_version: 1.30.0
app_file: app.py
pinned: false
license: mit
---


# AI Text Detector

A streamlit-based application that helps identify whether text was generated by AI or written by humans. Built using Streamlit and machine learning.

## Features

- Real-time text classification
- Minimum word count validation (100 words)
- User-friendly web interface
- Text preprocessing pipeline
- Clear visual feedback for results

## Demo

The application provides a simple yet powerful interface for checking text. Here's how it works:

### 1. Input Text

![Input Interface](images/1.png)

The main interface features a large text area where you can paste or type the text you want to check. The application requires a minimum of 100 words for accurate classification.

### 2. Results

![Results](images/2.png)

After submitting the text, the application will process it and display whether it appears to be human-written or AI-generated. The results are shown with clear visual indicators and informative messages.

## Setup

1. Create and activate a virtual environment:
   ```bash
   # Create virtual environment
   python -m venv venv
   
   # Activate virtual environment
   # Windows
   .\venv\Scripts\activate
   # Linux/MacOS
   source venv/bin/activate
   ```

2. Install the required dependencies:
```bash
pip install -r requirements.txt
```

3. Run the application:
```bash
python run.py
```

4. Open your web browser and navigate to `http://localhost:8501`

## Technical Details

The application uses a machine learning model trained to distinguish between AI-generated and human-written text. The preprocessing pipeline includes:
- Lowercasing
- Punctuation removal
- Stopword removal
- URL and email removal
- Number removal
- Non-printable character removal

## Model Training

The machine learning model used in this application was trained using the Jupyter notebook [generated-text-classification.ipynb](generated-text-classification.ipynb).

The trained model is saved as `models/best_model.joblib` and is loaded automatically when the application starts.

The model achieves 100% accuracy and an F1-score of 100, but its performance is constrained to data similar to what is presented in the training dataset. Therefore, it struggles to generalize across diverse data types. Nonetheless, it performs exceptionally well in distinguishing between AI-generated and human-generated text.

## Requirements

- Python 3.8+
- pip
- All dependencies listed in [requirements.txt](requirements.txt)

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the LICENSE file for details.