Synthetic-Image-Detection A deep learning model built with TensorFlow/Keras and deployed as a Streamlit app to classify images as either real photographs or AI-generated.
This model (best_real_vs_ai_detector.h5) detects whether an image is AI-generated or Real.
It is a fine-tuned VGG16 model trained on custom datasets of AI-generated and real images.
π Overview
The model outputs a single probability score:
- Values > 0.5 β REAL
- Values β€ 0.5 β AI-GENERATED
It is used in an interactive Streamlit web app that allows users to upload an image, get predictions, and provide feedback to continuously improve the system.
π§© Model Architecture
- Base: VGG16 (pretrained on ImageNet)
- Added Layers:
- Flatten
- Dense(512, ReLU)
- Dropout(0.5)
- Dense(1, Sigmoid)
- Loss Function: Binary Crossentropy
- Optimizer: Adam (learning rate = 1e-4)
- Input Size: 150 Γ 150 Γ 3 RGB
- Output: 1 neuron (binary classification)
π Folder Structure
project/
β
βββ app.py # Streamlit web interface
β
βββ models/
β βββ best_real_vs_ai_detector.h5 # Model file (auto-downloaded from Hugging Face)
β
βββ feedback/ # Saved feedback images from the Streamlit app
β βββ correct_real/
β βββ correct_ai/
β βββ incorrect_real/
β βββ incorrect_ai/
β
βββ requirements.txt # Dependencies for app and scripts
βββ README.md # Documentation
π» Usage
1οΈβ£ Install dependencies
pip install -r requirements.txt
2οΈβ£ Run the Streamlit app
streamlit run app.py
The first run will automatically download the model from Hugging Face into the models/ folder.
Then open the app in your browser:
http://localhost:8501
Upload an image, click Analyze, and the app will tell you if itβs Real or AI-Generated β with confidence percentage.
You can also provide feedback (Yes/No) to help future retraining.
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support