32

How I Use AI Across One of My Favorite Hobbies — Photography

 4 years ago
source link: https://towardsdatascience.com/how-i-use-ai-across-one-of-my-favorite-hobbies-photography-545a0908f7f6?gi=b93e8922f9d
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How I Use AI Across One of My Favorite Hobbies — Photography

Neural Networks for labeling, compression, effects and more!

Nov 11 ·3min read

Fni2eyB.jpg!web

You can read the article and follow along with the code in the repo:

Sort & Label Photos (Labeling in Github Repo)

An obvious application of AI to photography is an understanding of your photos. Adding metadata to your images, sorting and labeling your images, and ultimately saving you time, Neural Networks can be used in no time.

After a long day of collecting shots, you probably want to look back on your images and view them by category. With a Convolutional Neural Network we can take the typical classification task and use it for sorting our photos.

Here’s how I use a CNN in very few lines at all to sort my photos after a day of capturing photos…

This is used out of the command line. I could totally see this served as a web app for others to use or as a Streamlit application.

First, we load our model and define the directories of existing images and where sorted images will be placed…

Now we create a function for our prediction. We resize our 5568x3712 to 224x224 so it’s pre-trained model friendly. We convert to array, expand dimensions, etc.

Finally, we process our prediction. We create a new folder for the category if it doesn’t already exist. We place the images in their corresponding folder.

(I shortened the code to fit the gist on Medium.. full working code in repo. )

We start with our images unsorted in the SampleImages folder…

VZzAbmN.jpg

Labeling and sorting CLI… Repo

After running our script and performing inference, the labels will create folders for the images that haven’t yet been sorted. If a category already exists, it will stick the photo into that category without trying to create a new folder. You’ll notice that some categories might be broad or incorrect but will give you the general idea. For example, our Raspberry Pi is labelled as a modem and our wrist watch is labeled as a stopwatch.

JVNRryQ.png!web

Coming Next…

I plan to make articles on the rest of my use-cases for photography. Some of these include compression, effects, and upscaling. Keep up to date with the code in the repo.

Thanks for reading!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK