--- title: Generative Inference Demo emoji: 🧠 colorFrom: indigo colorTo: purple sdk: gradio sdk_version: 5.23.1 app_file: app.py pinned: false license: mit --- # Generative Inference Demo This Gradio demo showcases how neural networks perceive visual illusions through generative inference. The demo uses both standard and robust ResNet50 models to reveal emergent perception of contours, figure-ground separation, and other visual phenomena. ## Models - **Robust ResNet50**: A model trained with adversarial examples (ε=3.0), exhibiting more human-like visual perception - **Standard ResNet50**: A model trained without adversarial examples (ε=0.0) ## Features - Upload your own images or use example illusions - Choose between robust and standard models - Adjust perturbation size (epsilon) and iteration count - Visualize how perception emerges over time - Includes classic illusions: - Kanizsa shapes - Face-Vase illusions - Figure-Ground segmentation - Neon color spreading ## Usage 1. Select an example image or upload your own 2. Choose the model type (robust or standard) 3. Adjust epsilon and iteration parameters 4. Click "Run Inference" to see how the model perceives the image ## About This demo is based on research showing how adversarially robust models develop more human-like visual representations. The generative inference process reveals these perceptual biases by optimizing the input to maximize the model's confidence. ## Installation To run this demo locally: ```bash # Clone the repository git clone [repo-url] cd GenerativeInferenceDemo # Install dependencies pip install -r requirements.txt # Run the app python app.py ``` The web app will be available at http://localhost:7860 (or another port if 7860 is busy). ## About the Models - **Robust ResNet50**: A model trained with adversarial examples, making it more robust to small perturbations. These models often exhibit more human-like visual perception. - **Standard ResNet50**: A standard ImageNet-trained ResNet50 model. ## How It Works 1. The algorithm starts with an input image 2. It iteratively updates the image to increase the model's confidence in its predictions 3. These updates are constrained to a small neighborhood (controlled by epsilon) around the original image 4. The resulting changes reveal how the network "sees" the image ## Citation If you use this work in your research, please cite the original paper: [Citation information will be added here] ## License This project is licensed under the MIT License - see the LICENSE file for details.