AiLens is a full-stack web application designed to analyze text and scanned document images to determine whether content was generated by AI. The application features real-time AI probability scoring, supporting raw text input as well as image-based text extraction using optical character recognition (OCR).
- Frontend: Next.js 16, React 19, TypeScript, Tailwind CSS v4, and Tesseract.js for OCR.
- Backend: FastAPI with PyTorch and Hugging Face Transformers for inference.
- Model:
desklib/ai-text-detector-v1.01sequence classification model.
- Next.js (
16.3.0): React framework for server rendering and static site generation - React / React DOM (
19.2.8): UI component library - Axios (
^1.19.0): HTTP client for backend API interaction - Tesseract.js (
^7.0.0): Optical character recognition engine for extracting text from images - Tailwind CSS (
^4) & PostCSS: Utility-first CSS styling - TypeScript (
^5): Static type checking
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Access the application at
http://localhost:3000.
Important Compatibility Note: The underlying model architecture is incompatible with newer versions of Hugging Face
transformers.
- Python Version: Requires Python 3.12 (
>=3.12).- Transformers Version: Strictly pinned to
transformers==4.44.2.
transformers==4.44.2torch>=2.13.0fastapi>=0.141.1uvicorn>=0.52.1accelerate>=1.14.0pydantic>=2.13.4
-
Navigate to the backend directory:
cd backend -
Synchronize dependencies and set up the virtual environment:
uv sync
-
Start the FastAPI backend server:
uv run uvicorn main:app --reload
-
Navigate to the backend directory:
cd backend -
Create a virtual environment using Python 3.12:
python3.12 -m venv .venv
-
Activate the virtual environment:
- Windows (PowerShell):
.venv\Scripts\Activate.ps1
- Linux / macOS:
source .venv/bin/activate
- Windows (PowerShell):
-
Install required packages:
pip install "transformers==4.44.2" "torch>=2.13.0" "fastapi>=0.141.1" "uvicorn>=0.52.1" "accelerate>=1.14.0" "pydantic>=2.13.4"
-
Start the backend server:
uvicorn main:app --reload
The backend server will be available at http://localhost:8000.
This application utilizes the open-weight AI text detection model:
- Model URL: https://huggingface.co/desklib/ai-text-detector-v1.01
- Model Name:
desklib/ai-text-detector-v1.01 - Creator: Desklib
Credit belongs to Desklib for providing and publishing this AI text detection model.