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:
- 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:
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/retrain.py
Example Machine Learning project using Python and TensorFlow - kmturley/tensorflow-detect-logo
5. Run the training script using the following command to train the image model:
python -m src.retrain \
6. Create the classifier script. You can use this script at /src/classify.py
You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…
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 \
Check your results. In my case I get the following:
Hope that helps you get started with image classifiers!
Check out the full source code and example at: