Skip to content

dirtyread/GraphPipe-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphPipe-example

Simple GraphPipe usage example for tensorflow model. Prepared on the basis of documentation: https://oracle.github.io/graphpipe/#/guide/user-guide/overview

Simple quick start is here: https://oracle.github.io/graphpipe/#/guide/user-guide/quickstart

How to run GraphPipe via docker - simple example

  1. Get model from quick start example (see above) and save it on models/squeezenet.pb
curl https://oracle.github.io/graphpipe/models/squeezenet.pb > squeezenet.pb

It could be use custom pb model.

  1. Download GraphPipe docker image (in this example is cpu version: https://oracle.github.io/graphpipe/#/guide/servers/installation)
docker pull sleepsonthefloor/graphpipe-tf:cpu
  1. Now we have two way to run docker GraphPipe container:

    1. Running docker container with local model.
    docker run -it --rm -v <path to model>:/tmp/ -p 9000:9000 sleepsonthefloor/graphpipe-tf:cpu --model=/tmp/squeezenet.pb --listen=0.0.0.0:9000
    

    In this case, we need to use a volume mount in order to serve local models: ... -v :

    1. Running docker container with remote model (via http).

      1. Go into models and run python simple http server (in this example run on 8080 port)

      Model can share in other repository (e.g. bitbucket or github)

      cd model
      python -m http.server 8080
      

      then you'll see:

      then you'll see:

      1. Running docker container:
      docker run -it --rm -p 9000:9000 sleepsonthefloor/graphpipe-tf:cpu --model=https://loclhost:8080/squeezenet.pb --listen=0.0.0.0:9000
      
  2. Testing server: Run on web browser local address on port 9000:

http://localhost:9000 then you'll see:

How to use GraphPipe - simple example

  1. Install packages from requirements.txt
pip install -r requirements.txt
  1. Run script request_example.py

Script use classification to all images in /test_data

Obtained results:

For test_data\g1.png classification is: [546] electric guitar g1.png

For test_data\g2.png classification is: [546] electric guitar g2.png

For test_data\g3.png classification is: [402] acoustic guitar g3.png

How to convert model from H5 to PB

It's work fine in WSL2 (Windows 10/Ubuntu-20.04)

@see: https://oracle.github.io/graphpipe/#/guide/servers/converting?id=tensorflow-model-formats

  1. Download h5 model:
curl https://oracle.github.io/graphpipe/models/squeezenet.h5 > squeezenet.h5
  1. Run dockerized converter:
docker run -v "$PWD:/tmp/" sleepsonthefloor/graphpipe-h5topb:latest /tmp/squeezenet.h5 /tmp/converted_squeezenet.pb

About

Simple GrapPipe example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages