In [5]:
import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.path.append(module_path)
In [6]:
%load_ext autoreload
In [7]:
%aimport lucid
%aimport -tensorflow
%aimport -numpy
%aimport -sklearn
In [8]:
%aimport
Let's check that we're actually seeing the local version, not a package installed in site-packages. Th next cell should show the path at which you cloned the lucid repo, not a system path:
In [9]:
module_path = lucid.__path__[0]
print("Lucid was loaded from {}.".format(module_path))
assert os.path.abspath("..") in module_path
del module_path
In [6]:
import numpy as np
In [7]:
image = np.random.normal(loc=.5, scale=.1, size=(200,200))
In [15]:
# this is how you set log levels globally:
import logging
logging.getLogger('lucid').setLevel(logging.DEBUG)
# or per module:
# logging.getLogger('lucid.misc.io').setLevel(logging.INFO)
In [16]:
%autoreload
from lucid.misc.io import load, save, show
image = load('../tests/fixtures/noise.jpeg')
print(image.dtype)
show(image)
In [10]:
%autoreload
array = load("../tests/fixtures/noise.jpeg")
print(array.dtype, array.shape)
show(array, domain=None)
array
Out[10]:
In [11]:
show(load("https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"))
In [12]:
from lucid.optvis import objectives, param, transform, render
from lucid.modelzoo.vision_models import InceptionV1
In [13]:
model = InceptionV1()
model.load_graphdef()
In [14]:
_ = render.render_vis(model, "mixed3b_pre_relu:470", thresholds=(32, 256, 1024))
In [12]:
import os
repr(os.urandom(16))
Out[12]:
In [12]:
import numpy as np
from lucid.misc.channel_reducer import ChannelReducer
In [98]:
array = np.zeros((100,100,10), dtype=np.float32)
for d in range(array.shape[-1]):
array[:,:,d] = np.eye(100,100)
In [104]:
array += 0.1 * np.random.uniform(size=array.shape)
In [106]:
reducer = ChannelReducer(3, reduction_alg='PCA')
In [107]:
reducer.fit(array)
Out[107]:
In [108]:
reducer._reducer.components_
Out[108]:
In [109]:
reduced = reducer.transform(array)
In [110]:
show(np.dsplit(reduced, reduced.shape[-1]))
In [105]:
from lucid.misc.io import load, save, show
show(np.dsplit(array, array.shape[-1]))