PixelTruth is an AI-powered deepfake detection system for social media images. It uses a custom Convolutional Neural Network (CNN) with advanced preprocessing to classify images as real or AI-generated with 95% accuracy.
Dataset download link -https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces
- About
- Features
- Tech Stack
- Performance
- Installation
- Usage
- Project Structure
- Contributing
- GSSoC 2026
- License
With the rise of AI-generated media, detecting deepfakes has become critical for media integrity and combating misinformation. PixelTruth addresses this by providing a fast, accurate, and accessible deepfake detection tool built on deep learning.
It analyzes visual artifacts introduced during image synthesis and classifies images in real-time through an intuitive web dashboard.
- πΌοΈ Real-time image analysis β supports JPG, PNG, WebP formats
- π Confidence scores β shows probability of real vs. fake
- π¨ Modern Streamlit dashboard β glassmorphism UI with visual feedback
- β‘ Fast inference β lightweight model optimized for speed
- π¬ Custom preprocessing pipeline β enhanced artifact detection
| Tool | Purpose |
|---|---|
| Python | Core language |
| TensorFlow / Keras | CNN model training & inference |
| OpenCV | Image preprocessing |
| Streamlit | Web dashboard |
| NumPy / Matplotlib | Data handling & visualization |
| Metric | Value |
|---|---|
| Accuracy | 95% |
| Input Size | 96 x 96 px |
| Supported Formats | JPG, PNG, WebP |
All models produced by training scripts and executed by inference pipelines comply with the Canonical Model Version v1.0.0 contract.
- Model Version:
v1.0.0(MobileNetV2 backbone with embedded rescaling) - Raw Preprocessing: Images are resized to 96x96 pixels and converted to RGB order, with float32 pixel values kept in the range
[0.0, 255.0]. - Internal Model Scaling: The model embeds a Keras
Rescaling(scale=1./127.5, offset=-1.)layer as its first preprocessing step. This maps the raw[0.0, 255.0]inputs to the range[-1.0, 1.0](the canonical input range required by the pretrained MobileNetV2 backbone). - Consistency: Both training-time generators and inference-time pipelines pass raw
[0.0, 255.0]pixel values directly to the model, ensuring perfect compatibility between training and production environments.
β οΈ Prerequisites:
- Python Version: This project strictly requires Python 3.11. (Newer versions like Python 3.12 are currently incompatible with the required TensorFlow dependencies).
- Windows Users:
- You must have the Microsoft Visual C++ Redistributable installed to run TensorFlow.
- If the app crashes on launch with a DLL error, install
tensorflow-cpuinstead of standardtensorflow.
# 1. Clone the repository
git clone https://github.com/Piyush-Sharma788/PixelTruth.git
cd PixelTruth
# 2. Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txtPixelTruth also needs a trained model file before it can make predictions.
Set a direct download URL for the trained model (for example, a GitHub Release asset) and the app will fetch it automatically when it starts:
# On Linux/macOS
export PIXELTRUTH_MODEL_URL=https://your-release-link/deepfake_detection_model.h5
export PIXELTRUTH_MODEL_SHA256=<optional-sha256>
streamlit run app.py
# On Windows (Command Prompt)
set PIXELTRUTH_MODEL_URL=https://your-release-link/deepfake_detection_model.h5
set PIXELTRUTH_MODEL_SHA256=<optional-sha256>
streamlit run app.py
# On Windows (PowerShell)
$env:PIXELTRUTH_MODEL_URL="https://your-release-link/deepfake_detection_model.h5"
$env:PIXELTRUTH_MODEL_SHA256="<optional-sha256>"
streamlit run app.pyDownload the model with the helper script:
python scripts/download_model.py --url https://your-release-link/deepfake_detection_model.h5 --dest deepfake_detection_model.h5- Download or generate the trained Keras model.
- Save it as
deepfake_detection_model.h5in the project root, or setPIXELTRUTH_MODEL_PATHto the file location. - Restart the app after placing the model file.
If you keep the model in a different folder, export the path before launching Streamlit:
# On Linux/macOS
export PIXELTRUTH_MODEL_PATH=/full/path/to/deepfake_detection_model.h5
streamlit run app.py
# On Windows (Command Prompt)
set PIXELTRUTH_MODEL_PATH=C:\full\path\to\deepfake_detection_model.h5
streamlit run app.py
# On Windows (PowerShell)
$env:PIXELTRUTH_MODEL_PATH="C:\full\path\to\deepfake_detection_model.h5"
streamlit run app.pyIf you receive the model from a release asset or shared download link, copy it into the project root first:
cp /path/to/downloaded/deepfake_detection_model.h5 ./deepfake_detection_model.h5If you publish the model as a GitHub Release asset, the recommended setup is:
- Upload
deepfake_detection_model.h5to the release. - Copy the release asset URL into
PIXELTRUTH_MODEL_URL. - Optionally record the SHA256 checksum in
PIXELTRUTH_MODEL_SHA256. - Start the app with
streamlit run app.py.
# Run the Streamlit dashboard
streamlit run app.pyThen open your browser at http://localhost:8501, upload an image, and get instant results.
PixelTruth/
βββ app.py # Streamlit dashboard
βββ predict.py # Inference logic
βββ experiments/ # Model training & experiments
β βββ train.py # Model training (v1)
β βββ train_v2.py # Model training (v2)
β βββ train_v3.py # Model training (v3)
βββ scripts/ # Helper scripts
β βββ download_model.py # Model download helper
β βββ create_dummy_model.py
β βββ check_merge_conflicts.py
βββ requirements.txt # Dependencies
βββ Figure_1.png # Training result plot
βββ Figure_2.png # Evaluation plot
βββ README.md
We welcome contributions of all kinds! Whether you're fixing a bug, improving the UI, or adding new features β you're welcome here.
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'Add your feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
Please read CONTRIBUTING.md for detailed guidelines.
PixelTruth is participating in GirlScript Summer of Code 2026!
We have beginner-friendly issues ready. Look for issues labelled:
good-first-issuebeginner-friendlydocumentationenhancement
Feel free to explore open issues and start contributing!
This project is licensed under the MIT License β see the LICENSE file for details.
Built with β€οΈ for media integrity by Piyush Sharma
If you found this useful, please β star the repo!
- Improve heading hierarchy for better readability
- Ensure consistent spacing between sections
- Use proper Markdown formatting for code blocks and lists
- Align all installation and usage steps properly
- Introduction
- Features
- Tech Stack
- Installation
- Usage
- Project Structure
- Contribution Guidelines
- License
- Add badges (optional): build, license, contributors
- Add screenshots for better UI understanding
- Standardize code blocks for commands
Improve onboarding experience for new contributors and users by making README more structured, readable, and professional.