*** This is an overview of Tensorflow Study Group @ Honmachi held on August 25th. *** ***
Abbreviation for Google Cloud Platform. It's the Google version of AWS (Amazon Web Services). The billing system is complicated and I'm afraid to use it for a while, but this time I want to try ML Engine (a service that builds a model of Tensorflow) because it is very easy to create a server. I chose this.
https://cloud.google.com/
This time I would like to install tensorflow on a simple virtual machine and run it.
Create a new instance. I chose "Ubuntu 17" as the boot disk.
Access this instance using the "External IP" that will be assigned after it is created (replace the part labeled YOUR_IP with the IP you got here).
First, log in with ssh.
ssh ubuntu@YOUR_IP
Install the required packages.
sudo -i
apt -y update
apt -y upgrade
apt -y install python3-pip python3-dev
pip3 install --upgrade pip
pip3 install opencv-python tensorflow
exit
This time, I have introduced a package so that tensorflow works with Python3 (not 2.x). Check if the library can be loaded normally as follows.
$ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> node1 = tf.constant(3.0, dtype=tf.float32)
>>> node2 = tf.constant(4.0) # also tf.float32 implicitly
>>> print(node1, node2)
Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0", shape=(), dtype=float32)
>>>
--Reference: https://www.tensorflow.org/get_started/get_started
I have installed Tensorflow, but I want the tutorial code, so I'll get the source code from GitHub.
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow/tensorflow/examples/tutorials/mnist/
Click here for the simplest sample. The data set for learning and evaluating mnist (handwritten characters) is downloaded from the Internet, and the model construction and evaluation are completed in an instant.
python3 mnist_softmax.py
For the contents of this program, please refer to the following URL. (I'm not good at theory, so I'll escape from this area to the topic of how to put it to practical use ...)
--https://www.tensorflow.org/get_started/mnist/beginners (translated version)
(It's a little inconvenient because it's just made) I made an application that starts tensorflow when uploading an image from a browser to the server and displays the result of classifying the image. Also, since the sample code of tensorflow has been evaluated as it is without saving the model, there is also a modified code to save the model using Saver (train-*. Py).
git clone https://github.com/lumbermill/takachiho.git
sudo apt install apache2 php rake
cd ~/takachiho/webapps/01-tensorflow
#Deploy php
rake install
#Build and deploy a model
cd ~/takachiho/raspi/07-coffee
python3 train-mnist1.py --data_dir=/tmp/tensorflow/mnist/input_data/ --log_dir=/var/www/html/tensorflow/models/
The screen looks like this. If you are interested in the source code, please refer to the above repository.
First, install and download the sample program.
sudo pip3 install keras h5py
curl -O https://raw.githubusercontent.com/asataniAIR/Image_DL_Tutorial/master/VGG/VGG16_Demo.py
If you specify an image as an argument, it will guess what it is. Easy!
$ python3 VGG16_Demo.py sample.jpg
Using TensorFlow backend.
:
Omission
:
('n03947888', 'pirate', 0.98744524)
('n04147183', 'schooner', 0.010494102)
('n04606251', 'wreck', 0.0010530388)
('n03240683', 'drilling_platform', 0.00052914425)
('n03344393', 'fireboat', 0.00010963867)
(Keywords that I couldn't go into too much detail)
Recommended Posts