Skip to content

Detect NanoBanana-generated images using MobileNetV3 transfer learning

License

Notifications You must be signed in to change notification settings

codewithbro95/nanomango

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🥭 NanoMango: AI-Generated Image Detector

NanoMango is a Deep Learning project designed to distinguish between Real photographs and Fake (AI-generated) images specifically from Google Gemini 2.5 Flash Image Preview. It utilizes Transfer Learning with a MobileNetV3 Large architecture to achieve high accuracy with a lightweight footprint.

The project includes a training engine and a user-friendly web interface (Streamlit) for live testing but you have to run it locally.

⚠️ Note: This detector is trained specifically on images generated by NanoBanana (Google Gemini 2.5 Flash Image Preview). Performance on other AI-generated images or models may vary.

Preview

Inference: NanoMango Demo Interface

Training: NanoMango Demo Interface

Project Structure

NanoMango/
├── data/                  # Dataset folder (not included in repo)
│   ├── real/              # Real images from Open Images V7 dataset
│   └── fake/              # AI-generated images(not the pro for now)
├── app.py                 # Streamlit Web Interface for testing
├── train.py               # Main training script
├── environment.yml        # Conda environment dependencies
├── nanomango_best.pth     # Saved model weights (generated after training)
└── README.md              # Project documentation

🚀 Installation & Setup

This project uses a generic Conda environment to manage dependencies (PyTorch, Streamlit, Torchvision, etc.).

  1. Clone the repository:
git clone <your-repo-url>
cd NanoMango
  1. Create the Environment: Ensure you have Conda installed, then run:
conda env create -f environment.yml
  1. Activate the Environment:
conda activate nanomango

🧠 Training the Model

To train the model from scratch, ensure your data is organized in the data/ folder with two subdirectories: real and fake.

  1. Run the training script:
python train.py
  1. Process:
  • The script automatically detects your hardware (CUDA, Apple Silicon MPS, or CPU).
  • It fine-tunes a pre-trained MobileNetV3 Large model.
  • The best weights are saved automatically as nanomango_best.pth.

Model Configuration:

  • Base: MobileNetV3 Large (Pre-trained on ImageNet)
  • Input Size: 224x224 (Resized)
  • Classes: * 0: Fake
  • 1: Real (Note: PyTorch assigns these alphabetically: F comes before R)

🧪 Running the Web Demo

You can test the trained model using the built-in web interface.

  1. Start the App:
streamlit run app.py
  1. Use the Interface:
  • A browser tab will open at http://localhost:8501.
  • Step 1: Upload your nanomango_best.pth file.
  • Step 2: Upload any image (JPEG/PNG) to test.
  • The app will display the prediction and confidence score in real-time.

🛠 Tech Stack

  • Core Framework: PyTorch
  • Architecture: MobileNetV3 Large
  • Interface: Streamlit
  • Image Processing: Torchvision & Pillow

Acknowledgments

This project uses datasets from the following sources:

  • Real Images: Open Images V7 - A large-scale dataset of real photographs curated by Bitmind
  • Fake Images: NanoBanana - AI-generated images from the NanoBanana model, provided by Bitmind

Thank you to the open-source community and Bitmind for making these datasets publicly available on Hugging Face.

License

Apache License

About

Detect NanoBanana-generated images using MobileNetV3 transfer learning

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages