TruthShield AI is a media authenticity verification console for detecting AI-generated images and AI-generated text with local machine-learning models. It combines 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.
- 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 for image classification
- RoBERTa for 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 .gitignore because they are large binary artifacts. Keep them locally under ML/ when running the full app.
- Architecture: EfficientNet-B0
- Task: real image vs AI-generated image
- Reported validation accuracy: 92.8%
- Default model path:
ML/truthshield_aigc_efficientnet_b0_final.pth- Default class order:
real,fake- Architecture: RoBERTa base
- Dataset family: M4 machine-generated text detection dataset
- Task: human-written text vs AI-generated text
- Reported validation F1: 96.9%
- Default model path:
ML/text/truthshield_text_roberta_m4- Default class order:
human,aiThe 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.
Install:
- 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. .gitignore only 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.