Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows configuring more parameters @ settings.json #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ http://1.2.3.4/log.html

You can view the current image being processed:
```
http://1.2.3.4/input.jpg
http://1.2.3.4/image.jpg
```

You can view the current settings:
Expand Down Expand Up @@ -232,7 +232,7 @@ Inside deepdream/settings.json you'll find a settings file that looks like this:
```

You can change `maxwidth` to something larger like 1000 if you want
big output images for big input images, remeber that will you need more RAM memory
big output images for big input images, remember that will you need more RAM memory
for processing lager images. For testing `maxwidth` of 200
will give you results much faster. If you change the settings and
want to regenerate outputs for your input images, simply remove the
Expand Down Expand Up @@ -366,6 +366,18 @@ in this demo. Note that the ReLU and Dropout layers are not valid for deepdreami
"inception_5b/output"
```

Here's the full list of supported properties of `settings.json`:

Property Name | Default Value | Description
---------------|:-------------:|-------------
maxwidth | 400 | Maximum width in pixels of output images
iter_n | 10 | Number of iterations of the "deepdream" function
octave_n | 4 | Number of octaves
octave_scale | 1.4 | Scale of each octave
layer | "inception_4c/output" | The network layer to optimize
step_size | 1.5 | "make_step" parameter, step size
jitter | 32 | how much to "jitter" the image before processing

### The GUI

The final GUI is based on https://github.com/akoenig/angular-deckgrid.
Expand Down
12 changes: 9 additions & 3 deletions deepdream/deepdream.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def showarray(a, fmt='jpeg'):
display(Image(data=f.getvalue()))

with open("settings.json") as json_file:
json_data = json.load(json_file)
settings = json.load(json_file)
#print()


Expand Down Expand Up @@ -97,7 +97,7 @@ def deepdream(net, base_img, iter_n=10, octave_n=4, octave_scale=1.4, end='incep
return deprocess(net, src.data[0])


maxwidth = json_data['maxwidth']
maxwidth = settings.get('maxwidth', 400)
img = PIL.Image.open('input.jpg')
width = img.size[0]

Expand All @@ -111,7 +111,13 @@ def deepdream(net, base_img, iter_n=10, octave_n=4, octave_scale=1.4, end='incep
frame = img
#frame_i = 0

frame = deepdream(net, frame, end=json_data['layer'])
frame = deepdream(net, frame,
iter_n = settings.get('iter_n', 10),
octave_n = settings.get('octave_n', 4),
octave_scale = settings.get('octave_scale', 1.4),
end = settings.get('layer', 'inception_4c/output'),
step_size = settings.get('step_size', 1.5),
jitter = settings.get('jitter', 32))
#frame = deepdream(net, img, end='inception_3b/5x5_reduce')
#frame = deepdream(net, img, end='conv2/3x3')

Expand Down