Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Q-Trust AI πŸ”¬βš›οΈ

Hybrid Architecture for Synthetic Image Detection via Dual-Input Quantum Re-Uploading

Brazil Quantum Camp - Quantum Computing Solutions
Team Q-Trust AI


πŸ“Œ Overview

As AI-generated imagery becomes indistinguishable from real photographs, the need for robust detection methods is critical. Q-Trust AI presents a hybrid classical-quantum architecture that fuses deep visual features and spectral frequency signatures to classify images as real or synthetic.

Our key insight: generative models like GANs and Diffusion Models leave measurable spectral fingerprints - patterns invisible to the human eye but detectable in the frequency domain. By combining these spectral features with ResNet18 semantic embeddings inside a Variational Quantum Circuit (VQC), we exploit quantum entanglement to capture subtle cross-modal correlations.

Result: 90.75% accuracy and F1-Score of 0.9125 on the CIFAKE benchmark - operating in only 6 dimensions with 72 trainable quantum parameters, near-matching a classical SVM with 528 dimensions.


🧠 Architecture

Input Image (32Γ—32Γ—3)
    β”‚
    β”œβ”€β”€β–Ί ResNet18 (ImageNet, frozen + fine-tuned layer4)
    β”‚         └──► 512D ──► Linear(512β†’6) ──► tanhΓ—(Ο€/2) ──► semantic_enc (6D)
    β”‚
    └──► Radial FFT Power Spectrum (16 bins)
              └──► Linear(16β†’6) ──► tanhΓ—(Ο€/2) ──► spectral_enc (6D)
                                                          β”‚
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Variational Quantum Circuit    β”‚
                    β”‚   6 qubits Β· 4 Re-Upload layers β”‚
                    β”‚                                  β”‚
                    β”‚  RY(semantic[i]) ─ RZ(spectral[i]) per qubit  β”‚
                    β”‚  CNOT ring entanglement          β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                          ⟨Zβ‚€βŸ© ... ⟨Zβ‚…βŸ©  (6 Pauli-Z expectation values)
                                   β”‚
                              Linear(6β†’2) ──► Softmax ──► P(fake)

Key Design Choices

Component Choice Rationale
Visual Encoder ResNet18 (partial fine-tuning) Rich 512D semantic features; transfer learning from ImageNet
Spectral Encoder Radial FFT (16 bins, 32Γ—32 resolution) Captures GAN/diffusion sampling artifacts with full frequency granularity
Embedding Orthogonal Angle Embedding (RY + RZ) Semantic and spectral features occupy separate Bloch sphere axes - no destructive interference
Entanglement CNOT ring Propagates cross-modal correlations across all qubits
Re-Uploading 4 layers of Data Re-Uploading Transforms shallow VQC into a universal function approximator
Optimizer AdamW + Label Smoothing (Ξ΅=0.05) Stabilizes classical-quantum gradient interface; prevents overconfidence

πŸ“Š Results

Test Set Performance (400 images, never seen during training)

Model Accuracy F1-Score AUC-ROC Params (quantum) Input Dim
VQC Dual-Input (ours) 90.75% 0.9125 0.9563 72 6
MLP Equivalent (6D) 90.75% 0.9082 - ~50 6
Logistic Regression 90.25% - - - 528
SVM RBF (upper bound) 91.00% 0.9167 - - 528

The VQC with 6D input outperforms Logistic Regression trained on 528 dimensions, and ties the classical equivalent MLP on accuracy while surpassing it on F1-Score - suggesting the advantage comes from quantum expressivity via entanglement, not raw computational power.

Confusion Matrix Highlights

  • Synthetic recall: 96% - the model catches almost all fake images
  • Real precision: 85% - conservative bias ideal for anti-fraud systems
  • AUC-ROC of 0.9563 demonstrates robust discrimination across all thresholds

t-SNE Analysis

The 6 Pauli-Z observables produce clearer geometric separation between real and fake classes compared to the classical 6D equivalent, visually confirming the advantage of orthogonal multimodal encoding in quantum latent space.


πŸ—‚οΈ Repository Structure

q-trust-ai/
β”‚
β”œβ”€β”€ README.md                          # This file
β”œβ”€β”€ LICENSE
β”‚
β”œβ”€β”€ Q_Trust_AI_notebook.ipynb          # Full experiment notebook (Google Colab)
β”‚
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ ARCHITECTURE.md                # Detailed architecture walkthrough
β”‚   β”œβ”€β”€ EXPERIMENTS.md                 # Full experiment log (all tested architectures)
β”‚   └── final_report.pdf               # Official competition report (PT-BR)
β”‚
└── assets/
    └── architecture_diagram.png       # Architecture overview figure

βš™οΈ Setup & Reproduction

Requirements

pip install pennylane pennylane-lightning scikit-learn matplotlib seaborn kagglehub tqdm
pip install torch torchvision

Running the Notebook

The full experiment is contained in a single Google Colab notebook:

Open In Colab

All global constants controlling the experiment are defined at the top of Section 1. Key reproducibility parameters:

SEED        = 42       # Fixed across numpy, torch, random
N_QUBITS    = 6        # Qubits in the VQC
N_LAYERS    = 4        # Data Re-Uploading layers
TRAIN_SIZE  = 2000     # Balanced: 1000 REAL + 1000 FAKE
VAL_SIZE    = 400      # 200 + 200
TEST_SIZE   = 400      # 200 + 200 (isolated)

Dataset

We use the CIFAKE benchmark (Bird & Lotfi, 2024), automatically downloaded via kagglehub:

import kagglehub
path = kagglehub.dataset_download("bird-j/cifake-real-and-ai-generated-synthetic-images")

120,000 images of 32Γ—32 pixels: CIFAR-10 real photographs vs. Stable Diffusion 1.4 synthetic counterparts.


πŸ”¬ Sections of the Notebook

Section Description
1 - Setup & Imports Dependencies, global constants, reproducibility seed
2 - Dataset & FFT Features CIFAKE loading, radial power spectrum extraction
3 - Exploratory Analysis Visual samples, spectral signature comparison (real vs. fake)
4 - Architecture VQC circuit definition, ResNet encoder, Angle Embedding
5 - Hybrid Training Data augmentation, AdamW, Label Smoothing, training loop
6 - Test Evaluation Accuracy, F1-Score, AUC-ROC, confusion matrix
7 - Baseline Models SVM RBF, Logistic Regression, MLP 6D
8 - Comparative Analysis ROC curves, precision-recall, probability distributions
9 - Quantum Circuit Internals Pauli-Z observables, t-SNE of quantum latent space
10 - Computational Complexity P vs NP-hard framing; motivation for hybrid QML
11 - Conclusions & Next Steps Full results table, lessons learned, future directions

πŸš€ Next Steps

Direction Description Expected Impact
More Re-Uploading layers Increase N_LAYERS from 4 to 6–8 Higher accuracy
Strongly Entangling Layers Replace CNOT ring with denser entanglement Better multivariate correlation capture
Real quantum hardware Run on IBM Quantum or IonQ with SPSA optimizer Assess decoherence impact on accuracy
New generators Test against Midjourney, Flux2 (not just Stable Diffusion) Generalization evaluation
Quantum Natural Gradient Replace AdamW with QNG optimizer More stable quantum parameter updates
Larger datasets Full CIFAKE (120K) + other benchmarks Scalability assessment

πŸ‘₯ Team

Q-Trust AI - Brazil Quantum Camp 2026

Amanda Arruda Β· Caio Silva Β· Diogo Lacerda Β· Eduarda Mendes Β· Igor Oliveira Β· Paulo Aquino Β· Rebeca VitΓ³ria TenΓ³rio Β· VinΓ­cius Leal


πŸ“š References

  1. Bird, J. J., & Lotfi, A. (2023). CIFAKE: Image Classification and Explainable Identification of AI-Generated Synthetic Images. arXiv:2303.14126. https://arxiv.org/abs/2303.14126

  2. Blum, A. L., & Rivest, R. L. (1992). Training a 3-node neural network is NP-complete. Neural Networks, 5(1), 117-127.

  3. Citron, D. K., & Chesney, R. (2019). Deepfakes and the New Disinformation War. Boston University School of Law.

  4. PΓ©rez-Salinas, A., Cervera-Lierta, A., Gil-Fuster, E., et al. (2020). Data re-uploading for a universal quantum classifier. Quantum, 4, 226. https://arxiv.org/abs/1907.02085


πŸ“„ License

This project is released under the MIT License. See LICENSE for details.

About

Q-Trust: Classifying AI-generated images using Quantum Machine Learning algorithms. Developed at Brazil Qunatum Camp.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages