Skip to content

About

DeepDream zoom videos with prompts and a live browser editor.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

DeepDreamer

Endless "falling into the picture" videos made with DeepDream, the 2015 technique that makes a trained image-recognition network exaggerate whatever it sees until eyes, animals and objects grow out of noise. DeepDreamer zooms into the image frame after frame and keeps dreaming, so new shapes keep forming and morphing.

It runs locally on Windows with an NVIDIA GPU. It is controlled through settings.ini, or through an editor that runs in your browser.

What it can do

  • Dream videos at any resolution and frame rate, with VGG16 or GoogLeNet (the original DeepDream network) doing the dreaming. Zoom, swirl, colour cycling, strength, painting size and the kind of things that appear (eyes and spirals, birds, objects, animals) are all adjustable.
  • Motion stack: instead of a plain zoom, stack up to 8 motions (zoom, spin, drift, tilt, handheld shake, swirl, bulge, Möbius bend, kaleidoscope, ripple, liquid currents, melt, contour flow). Any setting can follow a curve over the video, and a live preview shows the deformation before you render.
  • Prompts: steer the dream toward a sentence with OpenAI CLIP RN50 (2021), or toward ImageNet object names such as "volcano, castle".
  • Start images: begin the dream from your own photo instead of noise.
  • Text to image: AttnGAN (2018) draws a bird or a rough everyday scene from a sentence. It shows its 64 → 128 → 256 px stages and which word drew which part. Any result can be used as a start image.
  • Browser editor: sliders with explanations, recipes, a "what to expect" readout with warnings, preview and render buttons with progress, a live view of the frame being dreamed, and a gallery of your videos that can load the settings each one used.
  • Long renders are saved in chunks, so an interrupted render resumes where it stopped. Finished videos are numbered (output\NN-dream_1080p30.mp4) and saved next to a copy of the settings that made them.

Requirements

  • Windows 10 or 11, 64-bit, with an NVIDIA GPU (the CPU fallback works but is very slow)
  • Internet for the first start (about 3 GB for PyTorch and the network weights)
  • Python is not required: if the PC has none that PyTorch supports (3.10 to 3.14), DeepDreamer.bat installs Python 3.12 into its own python\ folder, without administrator rights

Getting started

Double-click DeepDreamer.bat. That is all: it opens the editor in your browser.

The first time (or whenever something is missing or broken) the page shows an installation screen instead and installs everything itself: a private Python environment, PyTorch (the CUDA build that matches your NVIDIA driver, otherwise the CPU build) and the packages, then downloads the VGG16 network. When it is done the page turns into the editor. Keep the black window open while you use it; closing it stops the editor and any render.

Pick a recipe, press Save & preview, then Save & render when you like it. Or edit settings.ini and run venv\Scripts\python.exe dream.py --preview / dream.py yourself.

For the Text to image tab, run this once to download and prepare AttnGAN (about 315 MB):

venv\Scripts\python.exe attngan\setup_files.py

Sharing the GPU with other programs

The [gpu] section of settings.ini keeps a render polite while something else (say, a local LLM) uses the same card: vram_limit_gb caps the video memory it may take (auto = 80% of what is free at the start) and duty is the share of the time the GPU works, the rest being pauses between frames. If a render runs out of memory, lower the width and height (for example 960x540) or remove 1.0 from scales.

What's in the repository

Path What it is
dream.py The renderer: networks, the per-frame dream step, video writing, resuming
prompts.py Prompt guidance (CLIP and ImageNet classes)
settings.ini All render settings, each with a comment explaining it
editor/server.py, editor/index.html The browser editor: a small local web server (Python standard library only) and the page
editor/warp.js, editor/warp.css The editor's Motion tab: the motion stack and its live WebGL preview
video_motion.py Extracts a clip's motion (optical flow or codec vectors) for the Video motion module
attngan/generate.py AttnGAN text-to-image, ported to current PyTorch
attngan/setup_files.py Downloads the AttnGAN files and converts them to safe formats
DeepDreamer.bat The only launcher: finds or installs Python, starts the editor
editor/installer.py, editor/setup.html The first-run installation, and the page that shows its progress

Created when you use it, and not tracked by git: venv/, python/ (only if it had to be installed), output/ (your videos), work/ and work_preview/ (render chunks), preview.mp4, init_images/ (start images picked in the editor), clips/ and video_motion/ (clips for the Video motion module and their extracted motion) and the AttnGAN weights.

Tuning in brief

To get… Change
Shapes that hold longer before morphing a slower Zoom module in the Motion tab (each shape lasts about 0.7 ÷ zoom speed seconds)
Bigger shapes smaller scales, e.g. 0.12,0.2,0.3
Animals and objects instead of eyes object_bias 0.8–1
A faster start and a busier picture higher strength
A different video with the same look a different seed

The editor explains every setting and warns about combinations that look bad.

Motion stack

The editor's Motion tab replaces the single zoom with a stack of motion modules, saved as a [warp] section in settings.ini. Modules run top to bottom and only move the sampling grid, so a frame is still resampled once, however many there are. Rates are per second, so 30 and 60 fps move the same.

[warp]
stack = zoom, swirl, melt
edge = reflect                 ; reflect, wrap or smear: what fills the frame where motion pulls in the outside
prism = 0                      ; red and blue zoom slightly apart for rainbow trails
zoom.rate = 0.25 ~ sine(period=12, depth=0.3)   ; a value can follow a curve: sine, tri, saw, pulse, noise, ramp
swirl.rate = 1.2
swirl.pivot = 0.59, 0.33       ; centre, in frame heights from the middle (y up)
swirl.where = near 0.6 soft 0.4
melt.on = no                   ; kept, but switched off
  • The preview runs only the motion, on a stand-in picture (or the frame on the monitor), at 30 fps. Its Grid, Flow and Stress views and the Motion check show where the motion stretches or tears the picture.
  • Random warp (R) builds a new stack that stays inside the Motion check's limits; Re-roll settings (Shift+R) keeps the modules and draws new values.
  • An empty stack keeps the picture still: no motion at all.
  • Settings files from before the motion stack have no [warp] section. Their zoom_rate is read as a Zoom module and their rotate_rate as a Spin module wobbling on a sine, so older settings and videos still move the same way (minus the old warp's tiny drift). Recipes that set zoom_rate or rotate_rate now change the stack's Zoom and Spin.

Video motion

The Video motion module makes the dream move the way a clip you choose moves. Pick or drop a clip on its card (it is copied to clips\), then press Extract motion. The motion is worked out once and cached in video_motion\; a render extracts it itself if you skipped that.

video.clip = C:\...\clips\drive.mp4
video.source = flow            ; flow: smooth optical flow (RAFT) / codec: the clip's own H.264/H.265 motion vectors
video.loop = loop              ; loop, pingpong (plays back and forth) or hold (keeps the last frame's motion)
video.gaps = hold              ; codec only: blocks without a past vector keep the previous motion, or zero
video.amp = 1                  ; strength
video.speed = 1                ; clip speed (2 plays it twice as fast, and so moves twice as fast)
video.smooth = 0.3             ; blur of the motion field
video.offset = 0               ; where in the clip to start, 0 to 1
  • Optical flow follows everything that moves, smoothly. On this CPU-only PyTorch it takes about half a second per clip frame (clips are cut at 30 s).
  • Codec vectors read the motion the encoder stored. They are blocky and glitchy, like datamoshing, and take no time to extract. B-frames mostly point to the future and leave gaps; hold keeps the motion going there.
  • The clip is cropped to the video's shape the way start images are. Camera footage often moves much more per frame than a zoom; if the Motion check warns, lower the strength.
  • The editor's preview can show the clip's own first frame (Picture: Clip) to check that the motion follows it.

Credits

  • DeepDream: Mordvintsev, Olah and Tyka, Google, 2015
  • VGG16 and GoogLeNet ImageNet weights from torchvision
  • CLIP: OpenAI, 2021, loaded through open_clip
  • AttnGAN: Xu et al., CVPR 2018, taoxugit/AttnGAN (MIT licence). The network code in attngan/generate.py is adapted from it.

About

DeepDream zoom videos with prompts and a live browser editor.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages