Try a service locally¶
Useful video demos
This section requires having docker installed.
If you need to use docker in an environment without root privileges (eg. an HPC cluster) check udocker instead of docker.
1. Choose your module¶
Once we have chosen the Module page we will find that it has an associated docker container in DockerHub. For example, in the example we are running here, the container would be
deephdc/deep-oc-image-classification-tf. This means that to pull the docker image and run it you should:
$ docker pull deephdc/deep-oc-image-classification-tf
Docker images have usually tags depending on whether they are using
test and whether they use
gpu. Tags are usually:
cpu: master + cpu
gpu: master + gpu
cpu-test: test + cpu
gpu-test: test + gpu
So if you wanted to use gpu and the test branch you could run:
$ docker pull deephdc/deep-oc-image-classification-tf:gpu-test
Instead of pulling from Dockerhub you can choose to build the image yourself:
$ git clone https://github.com/deephdc/deep-oc-image-classification-tf
$ cd deep-oc-image-classification-tf
$ docker build -t deephdc/deep-oc-image-classification-tf .
2. Launch the API and predict¶
Run the container with
$ docker run -ti -p 5000:5000 -p 6006:6006 -p 8888:8888 deephdc/deep-oc-image-classification-tf
Once running, point your browser to http://127.0.0.1:5000/ui and you will see the API documentation, where you can test the module’s functionality, as well as perform other actions.
Go to the
predict() function and upload the file/data you want to predict (in the case of the image classifier this should be an image file). The appropriate data formats of the files you have to upload are often discussed in the module’s Marketplace page or in their Github README files.
The response from the
predict() function will vary from module to module but usually consists on a JSON dict with the predictions. For example the image classifier return a list of predicted classes along with predicted accuracy. Other modules might return files (eg. images, zips, …) instead of a JSON response.