Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Google Cloud Machine Learning service to predict with a locally retrained Inception model

I have locally retrained the Inception model using the retrain.py file from Google Code Lab TensorFlow for Poets and want to use Google Cloud machine Learning service to make predictions.

Specifically, I want to modify the retrain.py file, so my TensorFlow application is prepared for

gcloud beta ml predict --instances=INSTANCES --model=MODEL

(i.e., prediction only; no need for Google Cloud ML training ala gloud beta ml jobs submit training).

I understand conceptually that the retrain.py file must be modified as described in Preparing a Model.

But there is no complete answer showing all the lines of code in the retrain.py file after being modified. And the popularity of Google Code Lab TensorFlow for Poets and Pete Warden’s screencasts about retraining Inception makes one expect this to be a very common example of image classification among the TensorFlow community; which means an answer will benefit many in the community.

Will someone please answer with their version of the retrain.py file after being modified as described in Preparing a Model?

Note 1: I have researched my question to confirm it has not been answered…

… The question asked by Davide Biraghi and answered by JoshGC “Q: How predict an image in google machine learning” does not show any modifications to the retrain.py file that retrains the Inception model in Google Code Lab TensorFlow for Poets.

… The question asked by KlezFromSpace and answered by rhaertel80 (with helpful comments by Robert Lacok) “Q: Deploy Retrained inception model on Google cloud machine learning” does not show all the lines of code in the retrain.py file after being modified for: Defining outputs; Creating inputs; Supporting variable batch sizes; Using instance keys; Adding input and output collections to the graph; and Exporting (saving) the final model. (See above Preparing a Model.)

… The question asked by Vinkeet Kaushik and answered by Robert Lacok (with helpful comments by mrry) “Q: Export a basic Tensorflow model to Google Cloud ML” is not specific to the retrain.py file that retrains the Inception model in Google Code Lab TensorFlow for Poets.

Note 2: I assume the jpeg image for which prediction is to be made is

gcloud beta ml predict --instances=INSTANCES --model=MODEL

where INSTANCES is the path to a JSON file with information about the image as per the question asked by Davide Biraghi and answered by rhaertel80 “Q: How convert a jpeg image into json file in Google machine learning”

Note 3: I assume I will manually store the EXPORT and EXPORT.META files saved by the modified retrain.py file at the URL I use to create MODEL in Google Cloud Console.

like image 623
Chuck Finley Avatar asked Oct 18 '22 21:10

Chuck Finley


1 Answers

This posting yesterday by Google's Slaven Bilac appears to be the answer.

like image 122
Chuck Finley Avatar answered Nov 09 '22 05:11

Chuck Finley