Team Updates

Here's what the The Great Wave off Kanagawa would look like over Almaty, Kazakhstan!
Here's what the The Great Wave off Kanagawa would look like over Almaty, Kazakhstan!
eshaanmenonEshaan Menon
importos
importssl
fromtimeimporttime
fromurllib.requestimporturlopen
fromtempfileimportNamedTemporaryFile
# Set this appropriately.
# os.environ["THEANO_FLAGS"] = "device=cpu"
os.environ['KERAS_BACKEND'] ="theano"
importtheano
importnumpyasnp
importmatplotlib.pyplotasplt
fromscipy.miscimportimsave
fromneural_style.utilsimport*
fromneural_style.fast_neural_style.transformer_netimportget_transformer_net
classModel:
def__init__(self, model_path):
self.X=theano.shared(np.array([[[[]]]], dtype=floatX))
transformer_net=get_transformer_net(self.X, model_path)
Xtr=transformer_net.output
self.get_Xtr=theano.function([], Xtr)
self.ssl_context=ssl.SSLContext(ssl.PROTOCOL_TLSv1)
defstyle_image_by_path(self, path, size=None, output_path=None):
img=load_and_preprocess_img(path, size=size)
start=time()
self.X.set_value(img)
img_tr=self.get_Xtr()
img_tr=img_tr[0, :, :, :]
add_imagenet_mean(img_tr)
img_tr=img_tr[::-1].transpose((1, 2, 0))
img_tr=np.clip(img_tr, 0, 255).astype(np.uint8)
time_taken=int((time() -start) *1000)
print("Took {}ms".format(time_taken))
plt.figure(figsize=(10, 10))
plt.imshow(img_tr)
plt.axis("off")
ifoutput_pathisnotNone:
imsave(output_path, img_tr)
self.X.set_value(np.array([[[[]]]], dtype=floatX))
defstyle_image_by_url(self, url, size=None, output_path=None):
withNamedTemporaryFile(buffering=0) asf:
imdata=urlopen(url, context=self.ssl_context).read()
f.write(imdata)
f.flush()
os.fsync(f)
self.style_image_by_path(f.name, size, output_path)
model=Model("stained_glass.h5")
eshaanmenonEshaan Menon
Original Image from NASA earth world view
Original Image from NASA earth world view
M
Magzhan
There is original image which can be used as a reference for comparison.
There is original image which can be used as a reference for comparison.
M
Magzhan
Earth climate change can be illustrated using different painting styles in cups
Earth climate change can be illustrated using different painting styles in cups
M
Magzhan
Earth climate change can be illustrated using different painting styles in t shirts
Earth climate change can be illustrated using different painting styles in t shirts
M
Magzhan
Style transferred image
Style transferred image
M
Magzhan
NASA Logo

SpaceApps is a NASA incubator innovation program.