A PyTorch implementation of the DeepDream algorithm.
DeepDream is a fascinating computer vision algorithm that creates dreamlike hallucinogenic appearances in images. While there are many great implementations available, I wanted to create something more accessible and user-friendly.
This project offers two key features:
- A simple web interface built with
Streamlitwhere anyone can experiment with DeepDream without writing code - A cleaner implementation of layer access in PyTorch using forward hooks rather than hardcoded model redefinition. With this approach you could use any pretrained model not only the couple of hardcoded!
There are two ways to experience DeepDreaming:
- Play with the Streamlit demo
- Dream deeper with Jupyter Notebooks
Each approach has detailed guides below. Remember that DeepDream doesn't have a one-size-fits-all configuration - you'll get the best results by experimenting with different settings for each image!
The Streamlit app provides an intuitive interface for experimenting with DeepDream. Simply upload an image, adjust the parameters, and watch the algorithm transform your image into a dream-like visualization.
Note: The web demo may run slowly, especially on shared servers. For performance reasons, your input images will be downscaled to:
(224, 224)pixels for VGG and ResNet models(299, 299)pixels for Inception model
The default settings work well for most images, so you can get started right away. If you're curious about what each parameter does, just click the help button (❔) next to each control for a detailed explanation!
Help page is also present. Click here to gain more intuition about parameters availiable.
1. DeepDream Starter - Get started with the basic implementation and concepts!
2. DeepDream Tricks - Playing with different settings from gradient smoothing to image pyramid!
The notebook files in this repository are not pre-executed, as executing them would make the files too large to be displayed properly on GitHub. If you want to see the outputs, please use the Kaggle notebooks linked above or clone the repository and run them locally. Remember that each notebook needs to be configured with paths to input image directories before running.
Source notebooks available in this repository:
- DeepDream Tricks - Explore various techniques to enhance your DeepDream outputs
- DeepDream Guided - Learn how to transfer features between images
There is one pre-executed notebook available in a separate branch:
- DeepDream Starter - A beginner-friendly introduction to the DeepDream algorithm with outputs visible
Running the Streamlit app locally is recommended for better performance, especially if you have a GPU. Here's how to get started:
# 1. Clone the repository
git clone https://github.com/Lassa30/deepdreaming.git
cd deepdreaming
# 2. Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install the package and dependencies
pip install . # Install the package in standard mode
# OR for development mode:
pip install -e . # Install in editable mode for development
# 4. Run the Streamlit app
streamlit run app/main.pyThis project has been tested with Python 3.12.3, but should work with other recent Python versions as well.







