tuosun98 / R1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deploy mnist application in docker

Create the model

This model is python application with Concolutional Neural Networks.
After training for 20000 times. It will has about 99.5% accuracy.
The Model will be saved in a file folder called Save.

Set the docker

In this project the application will be deployed in the docker container.

First, put requirements,Dockerfile and app.py in the same filefolder.
And use the following command:

sudo docker build -t mnist-app:latest .

Second,run the Docker container
We can run our docker container for testing
sudo docker run -d -p 9042:9042 mnist-app

Finally,Check the container by:
sudo docker ps -a

[suntuo@suntuo-493 ~]$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                    PORTS                    NAMES
d82f65802166        mnist-app           "python app.py"     About an hour ago   Up About an hour          0.0.0.0:9042->9042/tcp   apple_tree

Set the Cassandra

Pull the cassandra image from the docker server.
For example, we can pull cassandra version 3.11.2

sudo docker pull cassandra:3.11.2

And then, deploy activitate cassandra container from the image.
sudo docker run -d --name "some-cassandra" -d -e cassandra:3.11.2

Link the container

Use the link function to create one-way link from application to Database.

sudo docker run -d -p --name some-cassandra --link some-cassandra:linkname mnist_app:latest /bin/bash

And then we enter the mnist container, use ping command to check the connection. We can found they connection successfully.
However, in Cassandra container, it will be failed. Because the link is one-way.

Upload the graph

From a terminal, load the filefolder with the graph willing to recognize.
Use the following to submit the graph.

use curl -X post -F @image=image_name.png "http://127.0.0.1:5000/predict

And we will get the result of recongnization.
And in the cassandra container

```cqlsh: use mykeyspace;
```cqlsh:mykeyspace> SELECT * FROM image_num;

image_num      | date                | mnist_result
---------------+---------------------+--------------
20190410130802 | 2019-04-10 13:08:02 |            4
20190410132058 | 2019-04-10 13:20:58 |            6
20190415140809 | 2019-04-15 14:08:09 |            3

Then we can find the data of this testing

About


Languages

Language:Python 99.0%Language:Dockerfile 1.0%