adjustments to torch-dreams example
genekogan opened this issue · comments
For torch-dreams example.
Some adjustments that would be nice:
-
make possible to pass image directly (via
ml4a.image.load_image
) into config or into the dreamer function, instead of having to save it to disk first. Like in the deepdream and neura_style examples. -
put
make_custom_func
into the wrapper (models/torch-dreams.py
). Best to abstract the low-level stuff. -
use ml4a native stuff to save/display images to keep things consistent between repos. I've already started that in the example, although i noticed some noisy artifacts that didn't go away with
np.clip
, maybe you can figure out what's going on there @Mayukhdeb.
-
This seems like a good idea for consistency, I'll first have to figure out how
ml4a.image.load_image
is different fromload_image
that's being used intorch_dreams
. -
make_custom_func
works only for selecting individual channels or layers (one at a time,and not blending/combining them, which is also possible if the user wants). Anyways I'll move it intotorch_dreams.utils
for easy access. -
Will take a closer look on this first
Feel free to assign me to this issue
- It just outputs a
PIL.Image
unlessto_numpy
is set to True, in which case it's converted to a numpy array.Lines 29 to 55 in 0fed58b
- for
ml4a.models.deepdream
, the user puts the desired objective (whether one or multiple channels or layers) into the config, and the model does the rest internally. This is for the sake of abstraction, to make it a higher-level API. The best of both worlds is to allow this high-level abstraction, but to also make sure that the API allows you access to the low-level stuff as well, like you have, as a "power user" might want to use them in ways that we can't predict.
- make possible to pass image directly (via
ml4a.image.load_image
) into config or into the dreamer function, instead of having to save it to disk first.
Quick update:
I made some more changes to torch-dreams v1.1.0 to load make it possible to load images either from the path or as a numpy.ndarray
.
It works on the config as:
config = {
"image": your_numpy_array, # could also be: np.array(your_PIL_image)
"layers": [layer1, layer2],
# others params
}
I'm planning to make a universal load_image
function that works on urls, image paths, numpy arrays and PIL images (similar to the one you made).