1. ML Goes Fruitful Workshop
Preeti Negi, Deepika Sharma, Esha Ahuja, Sudhir Verma, Vikash Sharma
July 6, 2017
2. Plan for the workshop
• Introduction (40 min)
[Machine Learning, ANN, Architecture, Key Takeaways,
Image Classification using TensorFlow]
• Problem Statement (10 min)
[Object Detection Case Study for fruit salad.]
• Hands-On End to End Solution (110 min)
[Training and Testing the model, Studying the analytics,
Optimizing the trained model]
• Conclusion (20 min)
[Summary,Experience (Challenges) sharing by speakers]
Fig: Manual to Automation using Machine Learning
3. Pre-requisites for Participants
• Laptop (if possible install Android Studio for app
deployment)
Download Android Studio
• Android mobile or raspberry pi (optional) with camera
attached for the workshop.
• Project Source Code available at Github Link .
4. Key Takeaways and Learnings
• Learning of TensorFlow library, python, Docker, machine learning classification
techniques (parameters for testing accuracy), Raspberry Pi/mobile app.
• Implementation of business use case in food processing industry.
• Understanding the integration of varied technologies such as python, machine
learning, IoT, mobile etc.
• Gaining confidence in machine learning to identify more scenarios in different
industry domains.
• Feeling of achievement by creating end to end machine learning fruit detection
application.
• Gaining insights in the latest trends in technologies.
5. • Healthcare- identifying diseases like tumors, diabetes, cancer
etc.
• Food Sector- provide useful information like nutritional value,
quality etc. of the fruits and vegetables.
• Agriculture Sector- identifying crop diseases or automation of
sorting, segregation and packaging.
• Retail- identifying the quality of the products and remov
defective products.
Vision and Business Use Cases Identified
6. Introduction
Machine learning is the subfield of computer science that, gives
"computers the ability to learn without being explicitly programmed."
Approaches :
• General Algorithms
• Artificial neural networks (ANN or NN)
• Reinforcement learning
• Support vector machines
• Clustering etc.
ML Algorithms can perform for e.g. the following tasks:
Image Classification, Face Recognition, Cancer Detection,
Age estimating, Play Chess etc.
7. Neural Network
What is a neural network (NN)
• In computer science Artificial Neural Network
is a principal copy of the brain
• It consists of many neurons
• Mostly it is a “autonomous” system
What are the tasks of NNs
• It only has ONE Job … It makes decisions
Average human makes 35 000 decisions a day
• ANNs use the same schema
ANNs make decisions based on given input
8. Closer look at the business case
Food Processing industry: To cater to the high demand of
automation in food processing industry, machine learning
object detection plays a vital role in the production. For this
workshop, we propose the fruit-salad processing scenario.
We trained image classification model using TensorFlow Lib.
We optimized the trained model to fit mobile/RaspberryPi
performing live actions(fruit detection using camera).
9. Process
Task: build object detection machine learning model using
Google TensorFlow Library
• Build an Image Classification using Google TensorFlow.
• Use Inception v3 network to retrain on example fruits:
Apple, Mango, Watermelon and Strawberry.
• Use python to train the image classifier.
• Classify images with trained classifier.
• Run TensorFlow on mobile device or raspberry pi.
10. Skills:
• Identify different fruits pictures.
• It is pretrained to identify-
Apples, Strawberries, Mangoes and
Watermelons.
Properties:
• Convolutional neural network (CNN)
• Based on Inception-V3(Powerful CNN
Structure)
• Uses TensorFlow
• Runs inside a Docker Container
• Uses transfer learning
• You can retrain it on fruits.
Fruit Detection with ANN
11. Docker
• Docker is the world’s leading software container platform.
• The demo can be used comfortably on several platforms.
• Demo runs in a Ubuntu Container (Virtual Machine).
TensorFlow
• An open-source software library for Machine Intelligence. It is
a framework for deep-learning
• Open Source(developed by google)
• Python Programming
Camera App to run Tensorflow
• Optimize your model.
• Compress your model.
• Run it in a pre-made Android app /Raspberry Pi.
Docker- TensorFlow – Android / RaspberryPi
14. Docker Setup
• Install Docker from the link: Install Docker
• Download from Docker Store.
15. Docker Setup
• Install
Double-click InstallDocker.msi to run the installer.
When the installation finishes, Docker starts automatically. The whale in the notification
area indicates that Docker is running, and accessible from a terminal.
• Run
Open a command-line terminal. Run docker run hello-world to verify that Docker can pull
and run images.
16. TensorFlow Setup
• Install:
After downloading your prompt should change to root@xxxxxxx:/notebooks#
Next check to confirm that your TensorFlow installation works by invoking Python from the
container's command line:
17. TensorFlow Setup
• Run
When python prompt, >>>, run the following code:
This should print Hello TensorFlow!
• Exit
Press Ctrl-d, on a blank line, once to exit python, and a second time to exit the docker image.
18. Relaunch Docker
• Create the working directory tf_files
• Relaunch Docker with above directory, and port number
6006 published for TensorBoard:
• Your prompt will change to root@xxxxxxxxx:/tf_files#
19. Retrieving Images - Github
• Extract the downloaded
project and extract all the zip
folders inside the project.
• Download project from Github
Link in zip format.
20. Retrieving Images – Github
• Move folders apple,
mango, strawberry and
watermelon to
fruits_train folder.
• Create a new folder
tf_files in C:/
• Move fruits_train,
fruits_test and
fruitClassify.py to tf_files
folder.
21. Retrieving Images - Docker
• Note the name of latest container in use for Docker.
• Copy the training data from local system to Docker:
22. Verifying Images in Docker
• Run the docker and verify the contents for tf_files
• Try the ls commands to validate the presence of training
images.
ls apple
ls mango , etc
23. (Re)training Inception
• Download retrain script manually to the current directory:
• Before starting the training, launch Tensorboard in the
background so you can monitor the training progress.
24. (Re)training Inception
• At this point, we have a trainer, we have data, so let's train!
We will train the Inception v3 network
• This step gives the final test accuracy after creation of
bottlenecks.
27. Using the Retrained Model
• Retraining script will write out a version of the Inception v3
network with a final layer retrained to your categories to
tf_files/retrained_graph.pb and a text file containing the
labels to tf_files/retrained_labels.txt
• To copy the fruits_test data and label_image.py to docker,
identify the latest container for docker first:
28. Classifying Script in Docker
• Copying fruits_test data and label_image.py to Docker
• Displaying contents for tf_files in Docker:
29. Classifying an Image
• Run the Python file and pass the image path as test data.
The script will classify the image for us.
31. Limitations for Mobile Device / Raspberry Pi
• Memory Constraints
• Computation power
Challenges :
• Memory overflow if we run the retrained graph directly without
optimization for both mobile device and raspberry.
• Performance issues in system when parameters like flip are
extensively used in re-training model.
Limitations / Challenges
32. Deployment on Android phone :
1. Copy the folder tf_android into docker
2. Launch docker with the directory tf_android
37. Steps:
10. Copy the graphs into the system folder android/assets/
11. Install Android Studio
Download
38. Step 12 : Android Phone Configuration
• Activate developer mode and usb debugging
• Settings->About Phone
• Scroll down to Build number
• Tap 7 times the build number to enable developer option
• You will see the message “you are now a developer”.
• Click back button-> you will see developer option -> enable USB
debugging
39. Steps: continued.
13. Open an existing android studio project
14. Select Android folder from tf_android
15. Gradle-sync the project
16. Connect the android phone using USB
17. Click on run in android studio.
18. Select the phone and run the app.
46. About Speakers
Preeti Negi:
Preeti has 9 years of industry experience with SAP Labs India Pvt. Ltd. She has worked on
innovation projects- Simplify Predictive Analytics for multiple industries solutions, Machine
Learning Image classification for fruit detection, Optimizing the usage of Learning Rooms
through IoT Solutions, Contract Approval SAP Fiori app.
Preeti was the speaker at various events:
SAP HANA & IoT Meet-Up Event 2016, SAP d-kom 2015 Silicon Valley (US), Official trainer for
‘Effective Communication with customers and colleagues’ workshops, Empowering Workshop
for Israel Customer.
Deepika Sharma
Deepika Sharma has 4 years of experience with SAP Labs India Pvt. Ltd. She has worked on
projects related to Internet of Things and Image Classification using Google Tensorflow.
47. About Speakers
Esha Ahuja:
Esha has been working in industry for 4 years. She has also worked on multiple development
projects & offered an internet of things solution as in-house project.
Esha was speaker at:
Delhi-NCR meet-up workshop in internet of things, hands-on workshop on SAP UI5 technology,
an official trainer for Fiori Advanced Development, SAP d-Kom event Bangalore.
Sudhir Verma
Linkedin Profile
Vikash Sharma
Vikash is working with SAP Labs India Pvt. Ltd. for almost 8 years. His functional and technical
expertise is in SAP GRC and SAP ABAP language. He has also worked on SAP HANA and he had
developed innovative, real time, SAP HANA based application i.e. SAP Rakshak 2.0. Vikash was
speaker multiple workshops and info pods for customers.