Learn how to use Deep Block's API and create your own app in this article.
We recently released an API for Deep Block, our web-based AI platform. To highlight the usage of our API we created an example project, it is a website that takes the camera input from your webcam and performs image segmentation to find your hair. The project can be found onGitHub. To run use the website yourself, take a look at the Readme file on GitHub.
With our API you can utilize the models you trained on Deep Block for your own AI applications.
To do this, you need to create a File object with the image data and set it as the 'files' entry in a FormData object which you put as the body of the request. You also need to put the projectID of the specific project you want to use as a parameter in the URL as shown above. Your API key and a current timestamp need to be specified as headers.
If you want to run inference on only the images you upload right now, you first need to make sure that the project does not contain any previously uploaded images for inference. To do this, you can use the remove predict files API call before uploading your images:
Here, thresholdScore is the level of confidence the model needs to have in its predictions. It has to be a value between 0 and 100. The higher the value, the higher the confidence, but fewer predictions will be made. For many applications, a value between 30 and 70 is reasonable.
To know when the inference is complete, you need to periodically check the status of the project. This can be done through this HTTP request:
This will return the predictions in the format of a JSON file which has the entries 'images', 'annotations' for each image, and 'categories'. You can use the predictions specified in 'annotations' to complete your task! Additionally, if you need an easy way to visualize the predictions of an image, we have an API call for that as well:
For this, you need to specify the imageID of the image you want to visualize. You can find it in the 'images' entry of the JSON file you just got. This HTTP request will return the visualized predictions as a base64 encoded image.