Using machine learning to identify old logos

Kim T
Kim T
Dec 6, 2019 · 2 min read
Image for post
Image for post

Some tasks are easy to automate, such as checking when your site was last modified. Or how old a file is. But how do you check whether the image contains an old logo?

In the past this is a task I would’ve done manually, to ensure every old image is found. But with machine learning it’s possible to train a neural network to identify two different scenarios and then have it detect which image it is closest to.

To accomplish this I started off using a Tensorflow code lab as a starting point:

  1. Install python dependencies. Create a file /requirements.txt and add the list of libraries required:

2. Create a python virtual environment and install the dependencies using:

virtualenv env
source env/bin/activate
pip install -r requirements.txt

3. Prepare your data. This is arguably the biggest task you’ll have, to get enough source files to give the script access to a variety of examples. Create two folders containing old and new examples of the logo.


4. Next create your training script. This will navigate to each image subdirectory and use the name as a classifier group, in this example two groups ‘old’ and ‘new’. I have prepared a script you can use at /src/

5. Run the training script using the following command to train the image model:

python -m src.retrain \
--bottleneck_dir=dist/bottlenecks \
--how_many_training_steps=500 \
--model_dir=dist/models \
--summaries_dir=dist/summaries \
--output_graph=dist/retrained_graph.pb \
--output_labels=dist/retrained_labels.txt \
--architecture="mobilenet_0.50_224" \
--image_dir=src/images \

6. Create the classifier script. You can use this script at /src/

7.Prepare some test images which are not part of the training data set. These will allow you to test the confidence scores of the results on unseen examples:


8. Run the classifier script using the command:

python -m src.classify \
--graph=dist/retrained_graph.pb \
--labels=dist/retrained_labels.txt \

Check your results. In my case I get the following:

Image for post
Image for post
Our image classifier has a high confidence detecting our examples.

Hope that helps you get started with image classifiers!

Check out the full source code and example at:

Creative Technology Concepts & Code

find, learn, share

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store