Detecting AI-generated images and AI-generated text with local machine-learning models β combining a cinematic React dashboard with a FastAPI inference backend, report exports, training visuals, and analyst-friendly evidence signals.
The system is designed as a major-project style prototype: it does not claim perfect proof, but gives calibrated risk signals that help a human reviewer decide what to inspect next.
- πΌοΈ Image AIGC detection using a locally trained EfficientNet-B0 model.
- βοΈ Text AI-generation detection using a locally trained RoBERTa model.
- 𧬠Hybrid text scoring that blends ML probability with writing-pattern signals.
- π Downloadable JSON, HTML, and PDF-style reports.
- π Training result visuals for the image and text models.
- π Incident library and training modules for awareness/education.
- π Dark cinematic dashboard UI built for repeated analyst work.
| Layer | Technologies |
|---|---|
| Frontend | React, TypeScript, Vite |
| Styling | Tailwind CSS, shadcn/ui, Radix UI |
| Icons | lucide-react |
| Backend | FastAPI, Uvicorn |
| ML | PyTorch, torchvision, Hugging Face Transformers |
| Models | EfficientNet-B0 (image classification), RoBERTa (text classification) |
.
|-- backend/
| |-- app.py # FastAPI inference server
| |-- requirements.txt # Python backend dependencies
| `-- README.md
|-- ML/
| |-- truthshield_aigc_efficientnet_b0_final.pth
| |-- training_ai_detector.png
| |-- download (1).png # image-model confusion matrix
| `-- text/
| |-- truthshield_text_roberta_m4/
| | |-- config.json
| | |-- model.safetensors
| | |-- tokenizer.json
| | `-- tokenizer_config.json
| `-- text_detector_training_plot.png
|-- src/
| |-- pages/
| |-- components/
| |-- lib/
| `-- integrations/
`-- package.jsonNote: model weights are intentionally ignored by
.gitignorebecause they are large binary artifacts. Keep them locally underML/when running the full app.
| Property | Value |
|---|---|
| Architecture | EfficientNet-B0 |
| Task | Real image vs. AI-generated image |
| Validation accuracy | 92.8% |
| Default model path | ML/truthshield_aigc_efficientnet_b0_final.pth |
| Class order | real,fake |
| Property | Value |
|---|---|
| Architecture | RoBERTa base |
| Dataset family | M4 machine-generated text detection dataset |
| Task | Human-written text vs. AI-generated text |
| Validation F1 | 96.9% |
| Default model path | ML/text/truthshield_text_roberta_m4 |
| Class order | human,ai |
The text detector also calculates writing-pattern signals such as lexical diversity, sentence variation, repetition, and length reliability. This helps avoid blindly trusting the classifier on short or casual text.
| Requirement | Notes |
|---|---|
| Node.js | 18+ |
| npm | β |
| Python | 3.10+ recommended |
| pip | β |
On Windows, PowerShell is recommended for the commands below.
Install JavaScript dependencies:
npm installStart the Vite dev server:
npm run devThe frontend usually runs at:
http://127.0.0.1:8080Open the detection page:
http://127.0.0.1:8080/detectionInstall Python dependencies:
pip install -r backend/requirements.txtStart the ML backend:
npm run ml:devEquivalent direct command:
python -m uvicorn backend.app:app --host 127.0.0.1 --port 8010The backend runs at:
http://127.0.0.1:8010Health check:
http://127.0.0.1:8010/healthUse two terminals.
Terminal 1
npm run ml:devTerminal 2
npm run devThen open:
http://127.0.0.1:8080/detectionGET /healthReturns loaded model paths, device, and class order.
POST /predict-imageForm-data:
file=<image file>Returns:
- verdict
- confidence
- model probability
- evidence signals
- recommended next steps
POST /predict-textJSON body:
{
"text": "Paste text to analyze..."
}Returns:
- verdict
- confidence
- RoBERTa probability
- writing-pattern score
- hybrid calibration signal
- recommended next steps
Optional backend overrides:
TRUTHSHIELD_MODEL_PATH=ML/truthshield_aigc_efficientnet_b0_final.pth
TRUTHSHIELD_CLASS_ORDER=real,fake
TRUTHSHIELD_TEXT_MODEL_PATH=ML/text/truthshield_text_roberta_m4
TRUTHSHIELD_TEXT_CLASS_ORDER=human,ai
TRUTHSHIELD_IMAGE_SIZE=224
TRUTHSHIELD_CONFIDENCE_THRESHOLD=0.65
TRUTHSHIELD_TEXT_MAX_LENGTH=256
TRUTHSHIELD_TEXT_CONFIDENCE_THRESHOLD=0.65
TRUTHSHIELD_TEXT_HYBRID_WEIGHT=0.72Frontend override for the local ML backend:
VITE_IMAGE_DETECTOR_URL=http://127.0.0.1:8010Create a production build:
npm run buildPreview the build:
npm run previewTruthShield should be used as a review aid, not as final proof.
- AI image detectors can fail on screenshots, compression, edits, crops, or images outside the training distribution.
- AI text detectors are inherently difficult and can be confused by short text, polished human writing, paraphrasing, translation, or grammar correction.
- Confidence is probabilistic, not legal or forensic certainty.
- Reports should be paired with source checks, metadata checks, and human review.
The repository ignores:
.envfiles- Kaggle tokens
- model weights and checkpoints
- generated logs
- large media files
- build outputs
If a secret or large model file was committed before being added to
.gitignore, remove it from git history separately..gitignoreonly prevents future tracking.
- Start backend with
npm run ml:dev. - Start frontend with
npm run dev. - Open
/detection. - Upload an AI-generated image.
- Paste a longer human-written and AI-generated text sample.
- Export the report as JSON or HTML.
- Show the training curves on the dashboard.
This is an academic/major-project prototype focused on local ML integration, explainable detection signals, and a polished analyst dashboard experience.
Built to make media verification explainable, one signal at a time. π‘οΈ