├── .gitignore
├── LICENSE
├── MANIFEST
├── README.md
├── batcountry
├── __init__.py
└── batcountry.py
├── demo.py
├── demo_bulk.py
├── demo_guided.py
├── demo_vis.py
├── docs
└── images
│ ├── clouds_and_antelope_example.jpg
│ └── clouds_and_starry_night_example.jpg
├── examples
├── output
│ ├── fear_and_loathing
│ │ ├── conv2_3x3_fal_01.jpg
│ │ ├── conv2_3x3_fal_02.jpg
│ │ ├── conv2_3x3_fal_03.jpg
│ │ ├── conv2_3x3_fal_04.jpg
│ │ ├── inception_3b_5x5_reduce_fal_01.jpg
│ │ ├── inception_3b_5x5_reduce_fal_02.jpg
│ │ ├── inception_3b_5x5_reduce_fal_03.jpg
│ │ ├── inception_3b_5x5_reduce_fal_04.jpg
│ │ ├── inception_4c_output_fal_01.jpg
│ │ ├── inception_4c_output_fal_02.jpg
│ │ ├── inception_4c_output_fal_03.jpg
│ │ └── inception_4c_output_fal_04.jpg
│ ├── jurassic_park
│ │ ├── conv2_3x3_jp_01.jpg
│ │ ├── conv2_3x3_jp_02.jpg
│ │ ├── conv2_3x3_jp_03.jpg
│ │ ├── conv2_3x3_jp_04.jpg
│ │ ├── conv2_3x3_jp_05.jpg
│ │ ├── conv2_3x3_jp_06.jpg
│ │ ├── inception_3b_5x5_reduce_jp_01.jpg
│ │ ├── inception_3b_5x5_reduce_jp_02.jpg
│ │ ├── inception_3b_5x5_reduce_jp_03.jpg
│ │ ├── inception_3b_5x5_reduce_jp_04.jpg
│ │ ├── inception_3b_5x5_reduce_jp_05.jpg
│ │ ├── inception_3b_5x5_reduce_jp_06.jpg
│ │ ├── inception_4c_output_jp_01.jpg
│ │ ├── inception_4c_output_jp_02.jpg
│ │ ├── inception_4c_output_jp_03.jpg
│ │ ├── inception_4c_output_jp_04.jpg
│ │ ├── inception_4c_output_jp_05.jpg
│ │ └── inception_4c_output_jp_06.jpg
│ ├── seeded
│ │ ├── clouds_and_antelope.jpg
│ │ └── clouds_and_starry_night.jpg
│ ├── simple
│ │ ├── simple_fal.jpg
│ │ ├── simple_jp.jpg
│ │ └── simple_matrix.jpg
│ ├── the_matrix
│ │ ├── conv2_3x3_matrix_01.jpg
│ │ ├── conv2_3x3_matrix_02.jpg
│ │ ├── conv2_3x3_matrix_03.jpg
│ │ ├── conv2_3x3_matrix_04.jpg
│ │ ├── inception_3b_5x5_reduce_matrix_01.jpg
│ │ ├── inception_3b_5x5_reduce_matrix_02.jpg
│ │ ├── inception_3b_5x5_reduce_matrix_03.jpg
│ │ ├── inception_3b_5x5_reduce_matrix_04.jpg
│ │ ├── inception_4c_output_matrix_01.jpg
│ │ ├── inception_4c_output_matrix_02.jpg
│ │ ├── inception_4c_output_matrix_03.jpg
│ │ └── inception_4c_output_matrix_04.jpg
│ └── visualizations
│ │ ├── octave_0-iter_0-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_1-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_2-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_3-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_4-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_5-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_6-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_7-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_8-layer_conv2_3x3.jpg
│ │ ├── octave_0-iter_9-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_0-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_1-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_2-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_3-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_4-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_5-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_6-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_7-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_8-layer_conv2_3x3.jpg
│ │ ├── octave_1-iter_9-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_0-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_1-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_2-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_3-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_4-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_5-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_6-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_7-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_8-layer_conv2_3x3.jpg
│ │ ├── octave_2-iter_9-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_0-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_1-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_2-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_3-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_4-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_5-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_6-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_7-layer_conv2_3x3.jpg
│ │ ├── octave_3-iter_8-layer_conv2_3x3.jpg
│ │ └── octave_3-iter_9-layer_conv2_3x3.jpg
├── run_bulk.sh
└── run_simple.sh
├── initial_images
├── antelope.jpg
├── clouds.jpg
├── fear_and_loathing
│ ├── fal_01.jpg
│ ├── fal_02.jpg
│ ├── fal_03.jpg
│ └── fal_04.jpg
├── jurassic_park
│ ├── jp_01.jpg
│ ├── jp_02.jpg
│ ├── jp_03.jpg
│ ├── jp_04.jpg
│ ├── jp_05.jpg
│ └── jp_06.jpg
├── seed_images
│ └── starry_night.jpg
└── the_matrix
│ ├── matrix_01.jpg
│ ├── matrix_02.jpg
│ ├── matrix_03.jpg
│ └── matrix_04.jpg
├── requirements.txt
├── setup.cfg
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | tmp.prototxt
2 |
3 | # Created by https://www.gitignore.io
4 |
5 | ### Linux ###
6 | *~
7 |
8 | # KDE directory preferences
9 | .directory
10 |
11 | # Linux trash folder which might appear on any partition or disk
12 | .Trash-*
13 |
14 |
15 | ### Python ###
16 | # Byte-compiled / optimized / DLL files
17 | __pycache__/
18 | *.py[cod]
19 |
20 | # C extensions
21 | *.so
22 |
23 | # Distribution / packaging
24 | .Python
25 | env/
26 | build/
27 | develop-eggs/
28 | dist/
29 | downloads/
30 | eggs/
31 | .eggs/
32 | lib/
33 | lib64/
34 | parts/
35 | sdist/
36 | var/
37 | *.egg-info/
38 | .installed.cfg
39 | *.egg
40 |
41 | # PyInstaller
42 | # Usually these files are written by a python script from a template
43 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
44 | *.manifest
45 | *.spec
46 |
47 | # Installer logs
48 | pip-log.txt
49 | pip-delete-this-directory.txt
50 |
51 | # Unit test / coverage reports
52 | htmlcov/
53 | .tox/
54 | .coverage
55 | .coverage.*
56 | .cache
57 | nosetests.xml
58 | coverage.xml
59 | *,cover
60 |
61 | # Translations
62 | *.mo
63 | *.pot
64 |
65 | # Django stuff:
66 | *.log
67 |
68 | # Sphinx documentation
69 | docs/_build/
70 |
71 | # PyBuilder
72 | target/
73 |
74 | ### OSX ###
75 | .DS_Store
76 | .AppleDouble
77 | .LSOverride
78 |
79 | # Icon must end with two \r
80 | Icon
81 |
82 |
83 | # Thumbnails
84 | ._*
85 |
86 | # Files that might appear in the root of a volume
87 | .DocumentRevisions-V100
88 | .fseventsd
89 | .Spotlight-V100
90 | .TemporaryItems
91 | .Trashes
92 | .VolumeIcon.icns
93 |
94 | # Directories potentially created on remote AFP share
95 | .AppleDB
96 | .AppleDesktop
97 | Network Trash Folder
98 | Temporary Items
99 | .apdisk
100 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Adrian Rosebrock
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/MANIFEST:
--------------------------------------------------------------------------------
1 | # file GENERATED by distutils, do NOT edit
2 | setup.cfg
3 | setup.py
4 | batcountry/__init__.py
5 | batcountry/batcountry.py
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # bat-country
2 | 
3 |
4 | > We can't stop here, this is bat country. — Raoul Duke
5 |
6 | The `bat-country` package is an **easy to use**, **highly extendible**, **lightweight Python module** for **inceptionism** and **deep dreaming** with Convolutional Neural Networks and Caffe. My contributions here are honestly pretty minimal. All the real research has been done by the [Google Research Team](http://googleresearch.blogspot.com/2015/06/inceptionism-going-deeper-into-neural.html) — I'm simply taking the [IPython Notebook](https://github.com/google/deepdream/blob/master/dream.ipynb), turning it into a Python module, while keeping in mind the importance of extensibility, such as custom step functions.
7 |
8 | If you're looking for a more advanced CNN visualization tool, check out Justin Johnson's [cnn-vis](https://github.com/jcjohnson/cnn-vis) library.
9 |
10 | ## Installation
11 | The `bat-country` packages requires [Caffe, an open-source CNN implementation from Berkeley](http://caffe.berkeleyvision.org/), to be already installed on your system. I detail the steps required to get Caffe up and running on your system in the [official bat-country release post](http://www.pyimagesearch.com/2015/07/06/bat-country-an-extendible-lightweight-python-package-for-deep-dreaming-with-caffe-and-convolutional-neural-networks/). An excellent alternative is to use the [Docker image](https://github.com/VISIONAI/clouddream) provided by Tomasz of Vision.ai. Using the Docker image will get you up and running quite painlessly.
12 |
13 | After you have Caffe setup and working, `bat-country` is a breeze to install. Just use pip:
14 |
15 |
$ pip install bat-country
16 |
17 | You can also install `bat-country` by pulling down the repository and `setup.py`:
18 |
19 | $ git clone https://github.com/jrosebr1/bat-country.git
20 | $ pip install -r requirements.txt
21 | $ python setup.py install
22 |
23 | ## A simple example
24 | As I mentioned, one of the goals of `bat-country` is simplicity. Provided you have already installed Caffe and `bat-country` on your system, it only takes 3 lines of Python code to generate a deep dream/inceptionism image:
25 |
26 | # we can't stop here...
27 | bc = BatCountry("caffe/models/bvlc_googlenet")
28 | image = bc.dream(np.float32(Image.open("/path/to/image.jpg")))
29 | bc.cleanup()
30 |
31 | After executing this code, you can then take the `image` returned by the `dream` method and write it to file:
32 |
33 | result = Image.fromarray(np.uint8(image))
34 | result.save("/path/to/output.jpg")
35 |
36 | And that's it!
37 |
38 | For more information on `bat-country`, along with more code examples, head over to the the official announcement post on the PyImageSearch blog:
39 |
40 | [http://www.pyimagesearch.com/2015/07/06/bat-country-an-extendible-lightweight-python-package-for-deep-dreaming-with-caffe-and-convolutional-neural-networks/](http://www.pyimagesearch.com/2015/07/06/bat-country-an-extendible-lightweight-python-package-for-deep-dreaming-with-caffe-and-convolutional-neural-networks/)
41 |
42 | ## Guided dreaming
43 | Google has also demonstrated that it's possible to *guide* your dreaming process by supplying a *seed image*. This method passes your input image through the network in a similar manner, but this time using your seed image to guide the output.
44 |
45 | Using `bat-country`, it's just as easy to perform *guided dreaming* as *deep dreaming*. Here's some quick sample code:
46 |
47 | bc = BatCountry(args.base_model)
48 | features = bc.prepare_guide(Image.open(args.guide_image), end=args.layer)
49 | image = bc.dream(np.float32(Image.open(args.image)), end=args.layer,
50 | iter_n=20, objective_fn=BatCountry.guided_objective,
51 | objective_features=features,)
52 | bc.cleanup()
53 |
54 | What's nice about this approach is that I "guide" what the output image looks like. Here I use a seed image of Vincent van Gogh's Starry Night and apply to an image of clouds:
55 |
56 |
57 |
58 | As you can see, the output cloud image after applying guided dreaming appears to mimic many of the brush strokes of Van Gogh's painting:
59 |
60 |
61 |
62 | Here's another example, this time using a seed image of an antelope:
63 |
64 |
65 |
66 | You can read more about guided dreaming, plus view more example images here:
67 |
68 | [http://www.pyimagesearch.com/2015/07/13/generating-art-with-guided-deep-dreaming/](http://www.pyimagesearch.com/2015/07/13/generating-art-with-guided-deep-dreaming/)
69 |
70 | ## Some visual examples
71 | Below are a few example images generated using the `bat-country` package:
72 |
73 | 
74 | 
75 |
76 | 
77 | 
78 |
79 | 
80 | 
81 |
82 | 
83 | 
84 |
85 | 
86 | 
--------------------------------------------------------------------------------
/batcountry/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'adrianrosebrock'
2 |
3 | # import the necessary packages
4 | from batcountry import BatCountry
--------------------------------------------------------------------------------
/batcountry/batcountry.py:
--------------------------------------------------------------------------------
1 | # import the necessary packages
2 | from __future__ import print_function
3 | from google.protobuf import text_format
4 | from cStringIO import StringIO
5 | from PIL import Image
6 | import scipy.ndimage as nd
7 | import numpy as np
8 | import caffe
9 | import os
10 |
11 | class BatCountry:
12 | def __init__(self, base_path, deploy_path=None, model_path=None,
13 | patch_model="./tmp.prototxt", mean=(104.0, 116.0, 122.0),
14 | channels=(2, 1, 0)):
15 | # if the deploy path is None, set the default
16 | if deploy_path is None:
17 | deploy_path = base_path + "/deploy.prototxt"
18 |
19 | # if the model path is None, set it to the default GoogleLeNet model
20 | if model_path is None:
21 | model_path = base_path + "/bvlc_googlenet.caffemodel"
22 |
23 | # check to see if the model should be patched to compute gradients
24 | if patch_model:
25 | model = caffe.io.caffe_pb2.NetParameter()
26 | text_format.Merge(open(deploy_path).read(), model)
27 | model.force_backward = True
28 | f = open(patch_model, "w")
29 | f.write(str(model))
30 | f.close()
31 |
32 | # load the network and store the patched model path
33 | self.net = caffe.Classifier(patch_model, model_path, mean=np.float32(mean),
34 | channel_swap=channels)
35 | self.patch_model = patch_model
36 |
37 | def dream(self, image, iter_n=10, octave_n=4, octave_scale=1.4,
38 | end="inception_4c/output", clip=True, step_fn=None, objective_fn=None,
39 | preprocess_fn=None, deprocess_fn=None, verbose=True, visualize=False,
40 | **step_params):
41 | # if a step function has not been supplied, initialize it as the
42 | # standard gradient ascent step
43 | if step_fn is None:
44 | step_fn = BatCountry.gradient_ascent_step
45 |
46 | # if the objective function has not been supplied, initialize it
47 | # as the L2 objective
48 | if objective_fn is None:
49 | objective_fn = BatCountry.L2_objective
50 |
51 | # if the preprocess function has not been supplied, initialize it
52 | if preprocess_fn is None:
53 | preprocess_fn = BatCountry.preprocess
54 |
55 | # if the deprocess function has not been supplied, initialize it
56 | if deprocess_fn is None:
57 | deprocess_fn = BatCountry.deprocess
58 |
59 | # initialize the visualization list
60 | visualizations = []
61 |
62 | # prepare base images for all octaves
63 | octaves = [preprocess_fn(self.net, image)]
64 |
65 | for i in xrange(octave_n - 1):
66 | octaves.append(nd.zoom(octaves[-1], (1, 1.0 / octave_scale,
67 | 1.0 / octave_scale), order=1))
68 |
69 | # allocate image for network-produced details
70 | detail = np.zeros_like(octaves[-1])
71 | src = self.net.blobs["data"]
72 |
73 | for octave, octave_base in enumerate(octaves[::-1]):
74 | h, w = octave_base.shape[-2:]
75 |
76 | if octave > 0:
77 | # upscale details from the previous octave
78 | h1, w1 = detail.shape[-2:]
79 | detail = nd.zoom(detail, (1, 1.0 * h/ h1, 1.0 * w / w1), order=1)
80 |
81 | # resize the network's input image size
82 | src.reshape(1, 3, h, w)
83 | src.data[0] = octave_base + detail
84 |
85 | for i in xrange(iter_n):
86 | step_fn(self.net, end=end, clip=clip, objective_fn=objective_fn,
87 | **step_params)
88 |
89 | # visualization
90 | vis = deprocess_fn(self.net, src.data[0])
91 |
92 | # adjust image contrast if clipping is disabled
93 | if not clip:
94 | vis = vis * (255.0 / np.percentile(vis, 99.98))
95 |
96 | if verbose:
97 | print("octave={}, iter={}, layer={}, image_dim={}".format(octave,
98 | i, end, vis.shape))
99 |
100 | # check to see if the visualization list should be
101 | # updated
102 | if visualize:
103 | k = "octave_{}-iter_{}-layer_{}".format(octave, i,
104 | end.replace("/", "_"))
105 | visualizations.append((k, vis))
106 |
107 | # extract details produced on the current octave
108 | detail = src.data[0] - octave_base
109 |
110 | # grab the resulting image
111 | r = deprocess_fn(self.net, src.data[0])
112 |
113 | # check to see if the visualizations should be included
114 | if visualize:
115 | r = (r, visualizations)
116 |
117 | return r
118 |
119 | @staticmethod
120 | def gradient_ascent_step(net, step_size=1.5, end="inception_4c/output",
121 | jitter=32, clip=True, objective_fn=None, **objective_params):
122 | # if the objective function is None, initialize it as
123 | # the standard L2 objective
124 | if objective_fn is None:
125 | objective_fn = BatCountry.L2_objective
126 |
127 | # input image is stored in Net's 'data' blob
128 | src = net.blobs["data"]
129 | dst = net.blobs[end]
130 |
131 | # apply jitter shift
132 | ox, oy = np.random.randint(-jitter, jitter + 1, 2)
133 | src.data[0] = np.roll(np.roll(src.data[0], ox, -1), oy, -2)
134 |
135 | net.forward(end=end)
136 | objective_fn(dst, **objective_params)
137 | net.backward(start=end)
138 | g = src.diff[0]
139 |
140 | # apply normalized ascent step to the input image
141 | src.data[:] += step_size / np.abs(g).mean() * g
142 |
143 | # unshift image
144 | src.data[0] = np.roll(np.roll(src.data[0], -ox, -1), -oy, -2)
145 |
146 | # unshift image
147 | if clip:
148 | bias = net.transformer.mean["data"]
149 | src.data[:] = np.clip(src.data, -bias, 255 - bias)
150 |
151 | def layers(self):
152 | # return the layers of the network
153 | return self.net._layer_names
154 |
155 | def cleanup(self):
156 | # remove the patched model from disk
157 | os.remove(self.patch_model)
158 |
159 | def prepare_guide(self, image, end="inception_4c/output", maxW=224, maxH=224,
160 | preprocess_fn=None):
161 | # if the preprocess function has not been supplied, initialize it
162 | if preprocess_fn is None:
163 | preprocess_fn = BatCountry.preprocess
164 |
165 | # grab dimensions of input image
166 | (w, h) = image.size
167 |
168 | # GoogLeNet was trained on images with maximum width and heights
169 | # of 224 pixels -- if either dimension is larger than 224 pixels,
170 | # then we'll need to do some resizing
171 | nW, nH = 244, 244
172 | if w != 244 or h != 244:
173 | image = np.float32(image.resize((nW, nH), Image.BILINEAR))
174 |
175 | (src, dst) = (self.net.blobs["data"], self.net.blobs[end])
176 | src.reshape(1, 3, nH, nW)
177 | src.data[0] = preprocess_fn(self.net, image)
178 | self.net.forward(end=end)
179 | guide_features = dst.data[0].copy()
180 |
181 | return guide_features
182 |
183 | @staticmethod
184 | def L2_objective(dst):
185 | dst.diff[:] = dst.data
186 |
187 | @staticmethod
188 | def guided_objective(dst, objective_features):
189 | x = dst.data[0].copy()
190 | y = objective_features
191 | ch = x.shape[0]
192 | x = x.reshape(ch,-1)
193 | y = y.reshape(ch,-1)
194 |
195 | # compute the matrix of dot-products with guide features
196 | A = x.T.dot(y)
197 |
198 | # select ones that match best
199 | dst.diff[0].reshape(ch, -1)[:] = y[:,A.argmax(1)]
200 |
201 | @staticmethod
202 | def preprocess(net, img):
203 | return np.float32(np.rollaxis(img, 2)[::-1]) - net.transformer.mean["data"]
204 |
205 | @staticmethod
206 | def deprocess(net, img):
207 | return np.dstack((img + net.transformer.mean["data"])[::-1])
208 |
--------------------------------------------------------------------------------
/demo.py:
--------------------------------------------------------------------------------
1 | # USAGE
2 | # python demo.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
3 | # --image initial_images/fear_and_loathing/fal_01.jpg \
4 | # --output examples/simple_fal.jpg
5 |
6 | # import the necessary packages
7 | from batcountry import BatCountry
8 | from PIL import Image
9 | import numpy as np
10 | import argparse
11 |
12 | # construct the argument parser and parse the arguments
13 | ap = argparse.ArgumentParser()
14 | ap.add_argument("-b", "--base-model", required=True, help="base model path")
15 | ap.add_argument("-l", "--layer", type=str, default="conv2/3x3",
16 | help="layer of CNN to use")
17 | ap.add_argument("-i", "--image", required=True, help="path to base image")
18 | ap.add_argument("-o", "--output", required=True, help="path to output image")
19 | args = ap.parse_args()
20 |
21 | # we can't stop here...
22 | bc = BatCountry(args.base_model)
23 | image = bc.dream(np.float32(Image.open(args.image)), end=args.layer)
24 | bc.cleanup()
25 |
26 | # write the output image to file
27 | result = Image.fromarray(np.uint8(image))
28 | result.save(args.output)
--------------------------------------------------------------------------------
/demo_bulk.py:
--------------------------------------------------------------------------------
1 | # USAGE
2 | # python demo_bulk.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
3 | # --images initial_images/the_matrix --output examples/output/the_matrix
4 |
5 | # import the necessary packages
6 | from __future__ import print_function
7 | from batcountry import BatCountry
8 | from imutils import paths
9 | from PIL import Image
10 | import numpy as np
11 | import argparse
12 |
13 | # construct the argument parser and parse the arguments
14 | ap = argparse.ArgumentParser()
15 | ap.add_argument("-b", "--base-model", required=True,
16 | help="base model path")
17 | ap.add_argument("-i", "--images", required=True,
18 | help="base path to input directory of images")
19 | ap.add_argument("-o", "--output", required=True,
20 | help="base path to output directory")
21 | args = ap.parse_args()
22 |
23 | # buy the ticket, take the ride
24 | bc = BatCountry(args.base_model)
25 | layers = ("conv2/3x3", "inception_3b/5x5_reduce", "inception_4c/output")
26 |
27 | # loop over the input directory of images
28 | for imagePath in paths.list_images(args.images):
29 | # loop over the layers
30 | for layer in layers:
31 | # we can't stop here...
32 | print("[INFO] processing `{}`".format(imagePath))
33 | image = bc.dream(np.float32(Image.open(imagePath)), end=layer)
34 |
35 | # write the output image to file
36 | filename = imagePath[imagePath.rfind("/") + 1:]
37 | outputPath = "{}/{}_{}".format(args.output, layer.replace("/", "_"), filename)
38 | result = Image.fromarray(np.uint8(image))
39 | result.save(outputPath)
40 |
41 | # do some cleanup
42 | bc.cleanup()
43 |
--------------------------------------------------------------------------------
/demo_guided.py:
--------------------------------------------------------------------------------
1 | # USAGE
2 | # python demo_guided.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
3 | # --image initial_images/clouds.jpg \
4 | # --guide-image initial_images/seed_images/starry_night.jpg \
5 | # --output examples/output/seeded/clouds_and_starry_night.jpg
6 |
7 | # import the necessary packages
8 | from batcountry import BatCountry
9 | from PIL import Image
10 | import numpy as np
11 | import argparse
12 |
13 | # construct the argument parser and parse the arguments
14 | ap = argparse.ArgumentParser()
15 | ap.add_argument("-b", "--base-model", required=True, help="base model path")
16 | ap.add_argument("-l", "--layer", type=str, default="inception_4c/output",
17 | help="layer of CNN to use")
18 | ap.add_argument("-i", "--image", required=True, help="path to base image")
19 | ap.add_argument("-g", "--guide-image", required=True, help="path to guide image")
20 | ap.add_argument("-o", "--output", required=True, help="path to output image")
21 | args = ap.parse_args()
22 |
23 | # we can't stop here...
24 | bc = BatCountry(args.base_model)
25 | features = bc.prepare_guide(Image.open(args.guide_image), end=args.layer)
26 | image = bc.dream(np.float32(Image.open(args.image)), end=args.layer,
27 | iter_n=20, objective_fn=BatCountry.guided_objective,
28 | objective_features=features,)
29 | bc.cleanup()
30 |
31 | # write the output image to file
32 | result = Image.fromarray(np.uint8(image))
33 | result.save(args.output)
--------------------------------------------------------------------------------
/demo_vis.py:
--------------------------------------------------------------------------------
1 | # USAGE
2 | # python demo_vis.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
3 | # --image initial_images/fear_and_loathing/fal_01.jpg \
4 | # --vis examples/output/visualizations
5 |
6 | # import the necessary packages
7 | from batcountry import BatCountry
8 | from PIL import Image
9 | import numpy as np
10 | import argparse
11 |
12 | # construct the argument parser and parse the arguments
13 | ap = argparse.ArgumentParser()
14 | ap.add_argument("-b", "--base-model", required=True, help="base model path")
15 | ap.add_argument("-l", "--layer", type=str, default="conv2/3x3",
16 | help="layer of CNN to use")
17 | ap.add_argument("-i", "--image", required=True, help="path to base image")
18 | ap.add_argument("-v", "--vis", required=True,
19 | help="path to output directory for visualizations")
20 | args = ap.parse_args()
21 |
22 | # we can't stop here...
23 | bc = BatCountry(args.base_model)
24 | (image, visualizations) = bc.dream(np.float32(Image.open(args.image)),
25 | end=args.layer, visualize=True)
26 | bc.cleanup()
27 |
28 | # loop over the visualizations
29 | for (k, vis) in visualizations:
30 | # write the visualization to file
31 | outputPath = "{}/{}.jpg".format(args.vis, k)
32 | result = Image.fromarray(np.uint8(vis))
33 | result.save(outputPath)
--------------------------------------------------------------------------------
/docs/images/clouds_and_antelope_example.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/docs/images/clouds_and_antelope_example.jpg
--------------------------------------------------------------------------------
/docs/images/clouds_and_starry_night_example.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/docs/images/clouds_and_starry_night_example.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/conv2_3x3_fal_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/conv2_3x3_fal_01.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/conv2_3x3_fal_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/conv2_3x3_fal_02.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/conv2_3x3_fal_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/conv2_3x3_fal_03.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/conv2_3x3_fal_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/conv2_3x3_fal_04.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_01.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_02.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_03.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_3b_5x5_reduce_fal_04.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_4c_output_fal_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_4c_output_fal_01.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_4c_output_fal_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_4c_output_fal_02.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_4c_output_fal_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_4c_output_fal_03.jpg
--------------------------------------------------------------------------------
/examples/output/fear_and_loathing/inception_4c_output_fal_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/fear_and_loathing/inception_4c_output_fal_04.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/conv2_3x3_jp_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/conv2_3x3_jp_01.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/conv2_3x3_jp_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/conv2_3x3_jp_02.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/conv2_3x3_jp_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/conv2_3x3_jp_03.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/conv2_3x3_jp_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/conv2_3x3_jp_04.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/conv2_3x3_jp_05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/conv2_3x3_jp_05.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/conv2_3x3_jp_06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/conv2_3x3_jp_06.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_01.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_02.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_03.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_04.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_05.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_3b_5x5_reduce_jp_06.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_4c_output_jp_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_4c_output_jp_01.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_4c_output_jp_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_4c_output_jp_02.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_4c_output_jp_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_4c_output_jp_03.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_4c_output_jp_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_4c_output_jp_04.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_4c_output_jp_05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_4c_output_jp_05.jpg
--------------------------------------------------------------------------------
/examples/output/jurassic_park/inception_4c_output_jp_06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/jurassic_park/inception_4c_output_jp_06.jpg
--------------------------------------------------------------------------------
/examples/output/seeded/clouds_and_antelope.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/seeded/clouds_and_antelope.jpg
--------------------------------------------------------------------------------
/examples/output/seeded/clouds_and_starry_night.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/seeded/clouds_and_starry_night.jpg
--------------------------------------------------------------------------------
/examples/output/simple/simple_fal.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/simple/simple_fal.jpg
--------------------------------------------------------------------------------
/examples/output/simple/simple_jp.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/simple/simple_jp.jpg
--------------------------------------------------------------------------------
/examples/output/simple/simple_matrix.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/simple/simple_matrix.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/conv2_3x3_matrix_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/conv2_3x3_matrix_01.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/conv2_3x3_matrix_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/conv2_3x3_matrix_02.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/conv2_3x3_matrix_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/conv2_3x3_matrix_03.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/conv2_3x3_matrix_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/conv2_3x3_matrix_04.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_01.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_02.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_03.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_3b_5x5_reduce_matrix_04.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_4c_output_matrix_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_4c_output_matrix_01.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_4c_output_matrix_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_4c_output_matrix_02.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_4c_output_matrix_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_4c_output_matrix_03.jpg
--------------------------------------------------------------------------------
/examples/output/the_matrix/inception_4c_output_matrix_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/the_matrix/inception_4c_output_matrix_04.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_0-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_0-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_1-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_1-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_2-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_2-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_3-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_3-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_4-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_4-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_5-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_5-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_6-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_6-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_7-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_7-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_8-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_8-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_0-iter_9-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_0-iter_9-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_0-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_0-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_1-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_1-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_2-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_2-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_3-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_3-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_4-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_4-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_5-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_5-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_6-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_6-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_7-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_7-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_8-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_8-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_1-iter_9-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_1-iter_9-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_0-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_0-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_1-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_1-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_2-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_2-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_3-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_3-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_4-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_4-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_5-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_5-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_6-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_6-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_7-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_7-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_8-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_8-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_2-iter_9-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_2-iter_9-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_0-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_0-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_1-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_1-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_2-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_2-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_3-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_3-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_4-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_4-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_5-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_5-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_6-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_6-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_7-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_7-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_8-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_8-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/output/visualizations/octave_3-iter_9-layer_conv2_3x3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/examples/output/visualizations/octave_3-iter_9-layer_conv2_3x3.jpg
--------------------------------------------------------------------------------
/examples/run_bulk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | python demo_bulk.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
4 | --image initial_images/fear_and_loathing \
5 | --output examples/output/fear_and_loathing
6 | python demo_bulk.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
7 | --image initial_images/the_matrix \
8 | --output examples/output/the_matrix
9 | python demo_bulk.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
10 | --image initial_images/jurassic_park \
11 | --output examples/output/jurassic_park
--------------------------------------------------------------------------------
/examples/run_simple.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | python demo.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
4 | --image initial_images/fear_and_loathing/fal_01.jpg \
5 | --output examples/output/simple/simple_fal.jpg
6 | python demo.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
7 | --image initial_images/the_matrix/matrix_01.jpg \
8 | --output examples/output/simple/simple_matrix.jpg
9 | python demo.py --base-model $CAFFE_ROOT/models/bvlc_googlenet \
10 | --image initial_images/jurassic_park/jp_01.jpg \
11 | --output examples/output/simple/simple_jp.jpg
--------------------------------------------------------------------------------
/initial_images/antelope.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/antelope.jpg
--------------------------------------------------------------------------------
/initial_images/clouds.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/clouds.jpg
--------------------------------------------------------------------------------
/initial_images/fear_and_loathing/fal_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/fear_and_loathing/fal_01.jpg
--------------------------------------------------------------------------------
/initial_images/fear_and_loathing/fal_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/fear_and_loathing/fal_02.jpg
--------------------------------------------------------------------------------
/initial_images/fear_and_loathing/fal_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/fear_and_loathing/fal_03.jpg
--------------------------------------------------------------------------------
/initial_images/fear_and_loathing/fal_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/fear_and_loathing/fal_04.jpg
--------------------------------------------------------------------------------
/initial_images/jurassic_park/jp_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/jurassic_park/jp_01.jpg
--------------------------------------------------------------------------------
/initial_images/jurassic_park/jp_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/jurassic_park/jp_02.jpg
--------------------------------------------------------------------------------
/initial_images/jurassic_park/jp_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/jurassic_park/jp_03.jpg
--------------------------------------------------------------------------------
/initial_images/jurassic_park/jp_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/jurassic_park/jp_04.jpg
--------------------------------------------------------------------------------
/initial_images/jurassic_park/jp_05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/jurassic_park/jp_05.jpg
--------------------------------------------------------------------------------
/initial_images/jurassic_park/jp_06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/jurassic_park/jp_06.jpg
--------------------------------------------------------------------------------
/initial_images/seed_images/starry_night.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/seed_images/starry_night.jpg
--------------------------------------------------------------------------------
/initial_images/the_matrix/matrix_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/the_matrix/matrix_01.jpg
--------------------------------------------------------------------------------
/initial_images/the_matrix/matrix_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/the_matrix/matrix_02.jpg
--------------------------------------------------------------------------------
/initial_images/the_matrix/matrix_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/the_matrix/matrix_03.jpg
--------------------------------------------------------------------------------
/initial_images/the_matrix/matrix_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jrosebr1/bat-country/894af13bd777ab8aa989baf520db074b97cfad9a/initial_images/the_matrix/matrix_04.jpg
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Pillow==2.9.0
2 | argparse==1.2.1
3 | decorator==3.4.2
4 | imutils==0.2.2
5 | matplotlib==1.4.3
6 | mock==1.0.1
7 | networkx==1.9.1
8 | nose==1.3.7
9 | numpy==1.9.2
10 | protobuf==2.6.1
11 | pyparsing==2.0.3
12 | python-dateutil==2.4.2
13 | pytz==2015.4
14 | scikit-image==0.11.3
15 | scipy==0.15.1
16 | six==1.9.0
17 | wsgiref==0.1.2
18 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [metadata]
2 | description-file = README.md
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 |
3 | setup(
4 | name='bat-country',
5 | packages=['batcountry'],
6 | version='0.2',
7 | description='A lightweight, extendible, easy to use Python package for deep dreaming and image generation with Caffe and CNNs',
8 | author='Adrian Rosebrock',
9 | author_email='adrian@pyimagesearch.com',
10 | url='https://github.com/jrosebr1/bat-country',
11 | download_url='https://github.com/jrosebr1/bat-country/tarball/0.1',
12 | license='MIT',
13 | install_requires=[
14 | 'Pillow==2.9.0',
15 | 'argparse==1.2.1',
16 | 'decorator==3.4.2',
17 | 'imutils==0.2.2',
18 | 'matplotlib==1.4.3',
19 | 'mock==1.0.1',
20 | 'networkx==1.9.1',
21 | 'nose==1.3.7',
22 | 'numpy==1.9.2',
23 | 'protobuf==2.6.1',
24 | 'pyparsing==2.0.3',
25 | 'python-dateutil==2.4.2',
26 | 'pytz==2015.4',
27 | 'scikit-image==0.11.3',
28 | 'scipy==0.15.1',
29 | 'six==1.9.0',
30 | 'wsgiref==0.1.2',
31 | ],
32 | keywords=['computer vision', 'machine learning', 'deep learning',
33 | 'convolutional neural network', 'deep dream', 'inceptionism'],
34 | classifiers=[],
35 | )
36 |
--------------------------------------------------------------------------------