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
- 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.
- Download GraphPipe docker image (in this example is cpu version: https://oracle.github.io/graphpipe/#/guide/servers/installation)
docker pull sleepsonthefloor/graphpipe-tf:cpu
-
Now we have two way to run docker GraphPipe container:
- 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 :
-
Running docker container with remote model (via http).
- 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:
- 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
-
Testing server: Run on web browser local address on port 9000:
- Install packages from requirements.txt
pip install -r requirements.txt
- 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
For test_data\g2.png classification is: [546] electric guitar
For test_data\g3.png classification is: [402] acoustic guitar
It's work fine in WSL2 (Windows 10/Ubuntu-20.04)
@see: https://oracle.github.io/graphpipe/#/guide/servers/converting?id=tensorflow-model-formats
- Download h5 model:
curl https://oracle.github.io/graphpipe/models/squeezenet.h5 > squeezenet.h5
- Run dockerized converter:
docker run -v "$PWD:/tmp/" sleepsonthefloor/graphpipe-h5topb:latest /tmp/squeezenet.h5 /tmp/converted_squeezenet.pb