Image Classification with Deep Learning, enabled by framework

Illustration-1: A few correctly predicted images using image classification in deep learning (Images A to E are correctly predicted at 99.99%, 99.59%, 75.47%, 99.71%, 95.37% probability). Input images are recognized as either ‘animeman’, ‘animewoman’, ‘realman’ or ‘realwoman’ (in sequence) based on previously trained-deep learning model, with 86.07% modeling (training) accuracy.

Machine Learning & Deep Learning

Illustration-2: A brief overview on the evolution and advancements in Artificial Intelligence since 1950.
Table-1: Three categories of Machine Learning.

A Cognitive Deep Learning Use-Case

Illustration-3a: A Virtual Server for this article that is running on Google Cloud Platform (GCP) Compute Engine equipped with GPU, that is ready and operational (started).
Illustration-3b: from local computer (Windows Subsystem for Linux) on Windows 10, connect to Google Cloud Platform (GCP) compute engine using ssh (secure shell)
Illustration-4a: State of single NVIDIA GPU: Tesla P4, with no process running — GPU Utilization is at 0%. The temperature is measured at 50oC, power consumption at 24W of 75W max, and GPU RAM usage at 583MB of 7611MB.
Illustration-4b: State of single NVIDIA GPU: Tesla P4, when running neural network computations — GPU Utilization is at 92%. The temperature is measured at 60oC, power consumption at 60W of 75W max, and GPU RAM usage at 3371MB of 7611MB.
Illustration-5: A quick overview of the purpose of doing Image Classification with deep learning in this article. A single library ( for computer vision functionalities) is loaded by doing import with Python programming language in Jupyter Notebook Interactive Development Environment.
Illustration-6a: Javascript code to run on browser to download URLs.
Illustration-6b: 4 files in 4 categories containing list of URLs, by doing Google Image Search from browser for each class and limiting the result to maximum: 500 URLs. Each .txt file contains list of 500 URL pointing to relevan images, according to Google.
Illustration-6c: The total number of image files in each of directory, after doing manual selection of images that do not belong to respective classes. Ready for modeling.
Illustration-7: Series of Phyton code running on Jupyter Notebook that is preparing the dataset. Images are downloaded from Google Images based on set of URLs that we have defined before.
Illustration-8: Visualizing random images from dataset in each category following images removal.
Illustration-9a: Load dataset (from all 4 categories) into memory for modeling.
Illustration-9b: Train our neural network for Image Classification with’s fit_one_cycle() function using resnet-50 neural network architecture, with 5 epochs. The measurement metric is error_rate.
Illustration-9c lr_find to find range of suitable learning rate values, for next training (optimization).
Illustration-9d: Further train our neural network with fit_one_cycle() function with new adjusted learning rate. Save the state of each stage every 2 epochs.
Illustration-10: A list of saved stage files, generated when we call’s function.
Illustration-11: The exported file from chosen training stage (a deep learning model, consists of neural network architecture as well as all the trained weights). For our case, this is about 102MB in stage-4.
Illustration-12: A typical AI data pipeline stages: 1. Data Preparation, 2. Modeling, 3. Inferencing.
Illustration-13: Correct Prediction of Test images: Images A to F are correctly predicted at 99.93%, 66.31%, 99.41%, 99.39%, 96.88%, 99.54% probability. An image is passed to the generated model to predict whether they are either one in 4 classes: ‘animeman’, ‘animewoman’, ‘realman’ or ‘realwoman’.
Illustration-14: Incorrect Prediction of a test image: This image is incorrectly predicted at 73.02% probability as ‘realwoman’,while the model is supposed to predict it as ‘animewoman’ in which this class has only reached 26.97% probability. An image is passed to the generated model to predict whether they are either one in 4 classes: ‘animeman’, ‘animewoman’, ‘realman’ or ‘realwoman’.

What’s Next?



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