GithubHelp home page GithubHelp logo

deepdream's Introduction

DeepDream

A containerized approach to making your own deep dream images

Dependencies

The only dependencies for this project are singularity, Python 3.5 or newer, an internet connection, and optionally an nvidia GPU with CUDA support. The actual ML frameworks are installed and managed by the singularity virtual environment, removing the need to install them on your system.

Set Up

To download the supported models and build the container with the dependencies, just run make and sit back and relax. The make process is network bottle-necked, so unless you have a multi-gigabit connection, there likely won't be any benefit of using a -j flag.

Running

To run the model on a set of images, execute ./main.py -s [source image directory] -d [destination image directory]. The main program will then automatically bind all the necessary directories to the singularity container and begin execution.

Arguments accepted

Flag Short Form Argument Type Default Use
--blend -b None Taken N/A When present, blends in a bit of the previously generated image to the new image. This allows some level of temporal stability when generating deep-dream videos. Assumes that the frames are in ascii-betical order
--destination -d Directory None, must to be set Selects the directory that processed images will be written to
--guide -g JPEG Image None When present, uses the specified image as a stylistic guide. When not present no style guide is used
--jitter -j Integer 32 Maximum displacement for the random translation applied to the images for each algorithm set
--maximize -l Layer inception_4c/output The layer within the neural net to maximize the activation on. Using lower leveled layers will generate more geometric dreams, and higher level layers will generate more recognizable objects
--model -m File bvlc_googlenet/bvlc_googlenet.caffemodel The caffe model to be used for the generation of dreams.
--no-gpu None Taken N/A When present, the neural network is forced to be run on the CPU. Currently this is accomplished by a separate conda environment within the environment container that only has a CPU version of caffe installed.
--num-iterations -n Integer 1 The number of iterations of the algorithm to be ran on each image. The larger this number, the more pronounced the dream like structures will be
--octave-count Integer 4 The number of "octaves" to be run on each image. Each octave will detect and bring out patterns at an increasing scale
--octave-scale Float 1.3 The amount to scale the size of features generated by each subsequent octave
--prototext -p File bvlc_googlenet/deploy.prototxt The prototext declaration of the caffe model being used
--source -s Directory None, must be set Selects the directory that raw images will be read from
--steps-per-octave Integer 10 The number of min-max steps to take on each individual octave during image generation. Has a similar effect to --num-iterations, but is applied in a different order

Running on Windows

If you're okay with running CPU-only models, you can install WSL2 and set up singularity in it and proceed with life as normal. If

If you want to run GPU based models, you will first need to install all of the dependencies:

  • CUDA: available for download with instructions from nvidia's website
  • Anaconda: available here
  • caffe-gpu: Installable through anaconda
  • numpy: Installable through anaconda
  • scipy: Installable through anaconda
  • pillow: Installable through anaconda
  • ipython: Installable through anaconda
  • protobuf: Installable through anaconda
  • numba: Installable through anaconda

Once the dependencies are installed, you can run the model directly, bypassing singularity using the src/dream.py file. Note that you wll need to supply the following arguments:

  • --prototext: The path the the proto text of the caffe model, usually has file extension of .prototxt or .prototxt, but this can vary.
  • --caffemodel: The path to the model data for the caffe model, usually has file extension of .caffemodel, but this can vary.
  • --source: The path to the folder of all images that should be processed
  • --destination: The path to the folder where the processed images should be saved

Other options are optional and can be used to fine tune image generation

Running on Mac

Uhhhhhhh.... have fun. I make no guarantee that this project will work for you, but the steps listed in the "running on windows" section should work for you ¯\_(ツ)_/¯

Let me know if you get it working.

TODO's

  • Multi-GPU: Add support for multi-GPU. This will be easy when blend is off, but will require some fancy transition-sensitive allocation logic for blended videos
  • GPU selection: Select what GPU (or GPUs if I get multi-GPU working) you want the model to use in multi-GPU systems
  • Better blend options: Right now the blend factor is just randomly selected each frame. It would be nice to include things like constant factors or Gaussian distributions
  • Style transfers: Spaghetti videos! I need to find the models for this...
  • Single Image Support: For when you only want to process a single image instead of a whole directory
  • Support for other image formats: Currently the program only supports jpegs... :(

deepdream's People

Contributors

pecon avatar tux2603 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

deepdream's Issues

subprocess for conda - command failed

Get the following error when running main.py with -no-gpu flag.

Processing /opt/images/source/IMG_0539.jpg /opt/miniconda/envs/cpu/.tmp9fz0yk__: line 3: 29149 Killed ./dream.py --num-iterations 1 --octave-count 4 --octave-scale 1.3 --steps-per-octave 10 --maximize inception_4c/output --jitter 32 --no-gpu ERROR conda.cli.main_run:execute(33): Subprocess for 'conda run ['./dream.py', '--num-iterations', '1', '--octave-count', '4', '--octave-scale', '1.3', '--steps-per-octave', '10', '--maximize', 'inception_4c/output', '--jitter', '32', '--no-gpu']' command failed. (See above for error)

I’m running on a DigitalOcean droplet with
Ubuntu 20.04.
Need help please!

NVIDIA binaries not found in Windows10/WSL 2

Describe the bug


$ python3 main.py -s ./in -d ./out
singularity exec --writable-tmpfs --pwd=/opt/src --nv -B caffe/models:/opt/models -B src:/opt/src -B ./in:/opt/images/source -B ./out:/opt/images/destination caffe.sif conda run --no-capture-output -n gpu ./dream.py --num-iterations 1 --octave-count 4 --octave-scale 1.3 --steps-per-octave 10 --maximize inception_4c/output --jitter 32
INFO: Could not find any NVIDIA binaries on this host!
FATAL: container creation failed: mount /proc/self/fd/9->/usr/local/var/singularity/mnt/session/rootfs error: can't mount image /proc/self/fd/9: kernel reported a bad superblock for squashfs image partition, possible causes are that your kernel doesn't support the compression algorithm or the image is corrupted


it says causes kernel so maybe wrong one i installed on WSL2
make done but following process doesn't

  • chmod -R 0777 /opt/miniconda/envs/
    INFO: Adding environment to container
    INFO: Creating SIF file...
    INFO: Build complete: caffe.sif

tried to solve but it's helpful if i get some advices !
(sorry I put wrong labels it's not bug "help needed" but can't change,)

  • Operating System: [WSL2, ubuntu20.04.1 ]
  • Singularity Version: [3.4.0-1]
  • Kernel Version (if applicable): [WSL2-Linux-Kernel]
  • GPU: [GeForce RTX2060]
  • GPU driver version: [Cuda compilation tools, release 11.1, V11.1.105]
  • Installed ram and swap space: [15GB ram, 2.7GB swap]

Additional context
python3,singularity,cuda installed.

Add windows compatibility

Describe the bug
A clear and concise description of what the bug is.

Expected behavior
A clear and concise description of what you expected to happen.

To Reproduce
Steps to reproduce the behavior:

System Specs (please complete the following information):

  • Operating System: [eg, ubuntu, arch]
  • Singularity Version: [eg, 3.6.3]
  • Kernel Version (if applicable): [eg, 5.8.0-2-amd64, 4.15.0-106-generic]
  • GPU: [eg, 1050ti, 2x2080s]
  • GPU driver version: [eg, 440.64]
  • Installed ram and swap space: [eg, 16GB ram, 8GB swap]

Additional context
Add any other context about the problem here.

Ignoring Source Layer Issue

Describe the bug
When I run
./main.py -s /home/ryan/DeepDreamVideo/render -d /home/ryan/DeepDreamVideo/Out

I get the below abridged version of the output... Any thoughts. I am on ubuntu 20.04. Installed everything in your guide seemingly to a tee.

I1217 17:33:30.645584 48159 net.cpp:200] inception_3a/relu_3x3 does not need backward computation.
I1217 17:33:30.645588 48159 net.cpp:200] inception_3a/3x3 does not need backward computation.
I1217 17:33:30.645592 48159 net.cpp:200] inception_3a/relu_3x3_reduce does not need backward computation.
I1217 17:33:30.645597 48159 net.cpp:200] inception_3a/3x3_reduce does not need backward computation.
I1217 17:33:30.645601 48159 net.cpp:200] inception_3a/relu_1x1 does not need backward computation.
I1217 17:33:30.645606 48159 net.cpp:200] inception_3a/1x1 does not need backward computation.
I1217 17:33:30.645613 48159 net.cpp:200] pool2/3x3_s2_pool2/3x3_s2_0_split does not need backward computation.
I1217 17:33:30.645618 48159 net.cpp:200] pool2/3x3_s2 does not need backward computation.
I1217 17:33:30.645622 48159 net.cpp:200] conv2/norm2 does not need backward computation.
I1217 17:33:30.645627 48159 net.cpp:200] conv2/relu_3x3 does not need backward computation.
I1217 17:33:30.645630 48159 net.cpp:200] conv2/3x3 does not need backward computation.
I1217 17:33:30.645635 48159 net.cpp:200] conv2/relu_3x3_reduce does not need backward computation.
I1217 17:33:30.645640 48159 net.cpp:200] conv2/3x3_reduce does not need backward computation.
I1217 17:33:30.645645 48159 net.cpp:200] pool1/norm1 does not need backward computation.
I1217 17:33:30.645649 48159 net.cpp:200] pool1/3x3_s2 does not need backward computation.
I1217 17:33:30.645654 48159 net.cpp:200] conv1/relu_7x7 does not need backward computation.
I1217 17:33:30.645658 48159 net.cpp:200] conv1/7x7_s2 does not need backward computation.
I1217 17:33:30.645665 48159 net.cpp:200] data does not need backward computation.
I1217 17:33:30.645685 48159 net.cpp:242] This network produces output prob
I1217 17:33:30.645758 48159 net.cpp:255] Network initialization done.
I1217 17:33:30.690448 48159 upgrade_proto.cpp:53] Attempting to upgrade input file specified using deprecated V1LayerParameter: /opt/model/model.caffemodel
I1217 17:33:30.721181 48159 upgrade_proto.cpp:61] Successfully upgraded file specified using deprecated V1LayerParameter
I1217 17:33:30.722543 48159 net.cpp:744] Ignoring source layer label_data_1_split
I1217 17:33:30.722993 48159 net.cpp:744] Ignoring source layer loss1/ave_pool
I1217 17:33:30.723001 48159 net.cpp:744] Ignoring source layer loss1/conv
I1217 17:33:30.723004 48159 net.cpp:744] Ignoring source layer loss1/relu_conv
I1217 17:33:30.723007 48159 net.cpp:744] Ignoring source layer loss1/fc
I1217 17:33:30.723011 48159 net.cpp:744] Ignoring source layer loss1/relu_fc
I1217 17:33:30.723012 48159 net.cpp:744] Ignoring source layer loss1/drop_fc
I1217 17:33:30.723016 48159 net.cpp:744] Ignoring source layer loss1/classifier
I1217 17:33:30.723019 48159 net.cpp:744] Ignoring source layer loss1/loss
I1217 17:33:30.723655 48159 net.cpp:744] Ignoring source layer loss2/ave_pool
I1217 17:33:30.723666 48159 net.cpp:744] Ignoring source layer loss2/conv
I1217 17:33:30.723670 48159 net.cpp:744] Ignoring source layer loss2/relu_conv
I1217 17:33:30.723676 48159 net.cpp:744] Ignoring source layer loss2/fc
I1217 17:33:30.723680 48159 net.cpp:744] Ignoring source layer loss2/relu_fc
I1217 17:33:30.723682 48159 net.cpp:744] Ignoring source layer loss2/drop_fc
I1217 17:33:30.723685 48159 net.cpp:744] Ignoring source layer loss2/classifier
I1217 17:33:30.723688 48159 net.cpp:744] Ignoring source layer loss2/loss
I1217 17:33:30.725492 48159 net.cpp:744] Ignoring source layer loss3/loss3

Expected behavior
A clear and concise description of what you expected to happen.

To Reproduce
Steps to reproduce the behavior:

System Specs (please complete the following information):

  • Operating System: ubuntu
  • Singularity Version: version: 3.6.4
  • Kernel Version (if applicable): [eg, 5.8.0-2-amd64, 4.15.0-106-generic]
  • GPU: 1080ti
  • GPU driver version: 455
  • Installed ram and swap space: 64gb ram 500gbswap

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.