Monday, September 12, 2016

Google's Deep Dream

Google's Deep Dream enhances patterns in an image similar to the way your mind perceives a face in the moon, an algorithmic pareidolia. I recently found a Jupyter Notebook, published by Google, showing how to produce the Deep Dream visuals. I thought I'd give it a shot.

If you have never heard of Deep Dream, this GIF shows its effect on an image.
This GIF shows how the number of Deep Dream iterations affects the image.

GitHub is not able to show two of the GIFs I created in my notebook due to file size limitations. I included them in this blog post (one I converted to video).


This video was made by applying the Deep Dream filter, zooming in, and looping that 200 times. There are some noticeable differences between this video and the original GIF

Here's how I used the Deep Dream program


I'm happy with how it turned out. I was able to see the capabilities of Deep Dream by iterating through various settings. I was able to use Python to turn the generated images into labeled GIFs and tiled images. I think it turned out to be an effective way to display the data.


Installation

This Notebook uses Python Imaging Library (PIL) which has yet to release a version for Python 3.X, so I'll need to run the notebook on Python 2.7. Good thing Anaconda makes managing different Python environments easy. I wonder why Google didn't use Pillow instead and run the project on Python 3.

Installing Caffe was more difficult than I expected. Some issues I came across are:
  • Instead of using a package manager, Caffe needs to be built with Visual Studio.
  • There are multiple versions of Caffe for Windows available on GitHub. The two I tried were from Berkeley Vision and Learning Center (BVLC) and Microsoft. 
    • When I tried to build Microsoft's Caffe, the build failed. This was due to the build requiring a debug version of Python. Oddly the installation instructions made no mention of this requirement. It's only mentioned in the .PROPS file where the build's variables are set. 
    • I was able to build the BVLC version of Caffe, even though it mentioned the same debug requirement in the .PROPS file. 


The Microsoft Surface I'm running this on has an integrated GPU, which does not support NVIDIA's CUDA. I had to use a CpuBuildOnly build. At default settings it took about 5 minutes to render an image using most filters. I would look into a GPU build for a larger project.

GitHub link for this project

For more Deep Dreams, see this Instagram.

Saturday, July 23, 2016

What's in this folder?

Are you ever unsure what files are on in a folder on your computer or network drive? Small folders are easy to click and see, but large folders with many subfolders can be too much to look through.

Using Python, I made a script to walk through a file directory and output the data in an easy to read tabular format.

Here's the project on GitHub.


Tkinter GUI

I added a basic GUI using Tkinter. Tkinter has a file dialogue that works for selecting a folder. The user has the option to specify how far down the directory to see. The user also can toggle if file names in the folders will be included in the output.


Tkinter GUI
File dialogue GUI

Output

The output includes the path, folder/file name, folder/file size, count of files and folders both in that folder and subfolders, and a list of file types sorted by occurrence. A list of files in the folders can also be added to the list. The output is saved as a CSV file. The output file name is based on the name of the directory, so the script can be ran for multiple directories without overwriting other searches.

Example Output



Saturday, June 25, 2016

Numpy on NOAA Weather Data in IPython Notebook




I've been meaning to use Python more for data analysis. I took a Lynda class focusing on Matplotlib, Numpy and Pandas. This post focuses on the exercise analyzing NOAA weather data using Numpy and Matplotlib. Here is the IPython Notebook on GitHub. GitHub will allow you to view the notebook as an HTML document.