Skip to content

Lassa30/deepdreaming

Repository files navigation

DeepDreaming

A PyTorch implementation of the DeepDream algorithm.

Dreaming...
🔃

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:

  1. A simple web interface built with Streamlit where anyone can experiment with DeepDream without writing code
  2. 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!

Getting Started

There are two ways to experience DeepDreaming:

  1. Play with the Streamlit demo
  2. 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!

Web Demo

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.

Notebooks

Kaggle Notebooks

1. DeepDream Starter - Get started with the basic implementation and concepts!

DeepDream Starter Kaggle

2. DeepDream Tricks - Playing with different settings from gradient smoothing to image pyramid!

DeepDream Tricks Kaggle

3. DeepDream Guided - Discover how we can transfer features from one image to another.

DeepDream Guided Kaggle

🌌 Space ➡️ Yoda 👽

🐊 Crocodilo ➡️ Space 🌌

🌳 Tree ➡️ Yoda 👽

🐊 Crocodilo ➡️ Tree 🌳

GitHub Notebooks

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:

There is one pre-executed notebook available in a separate branch:

  • DeepDream Starter - A beginner-friendly introduction to the DeepDream algorithm with outputs visible

Run Locally

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.py

This project has been tested with Python 3.12.3, but should work with other recent Python versions as well.

Acknowledgements

  • Google initial DeepDream implementation helped me a lot with guided dreaming: GitHub
  • The AI Epiphany - is my source of inspiration for this project: YouTube, GitHub

License

About

✨ PyTorch implementation of DeepDream algorithm with a nice web demo.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors