-
-
Save gdoteof/e711f0c2908bc6b8ddac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# A simple command line utility to send an image to VMX For this | |
# example to work, make sure the VMX variable points to the location | |
# of your server. | |
# | |
# Tom Malisiewicz [email protected] | |
# vision.ai 2015 | |
#The location of the VMX server | |
VMX=http://localhost:3000 | |
#VMX=https://demo.vision.ai | |
#Make sure we have two command line arguments | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 model_name image_url" >&2 | |
exit | |
fi | |
#Check to make sure VMX is up and running | |
if [ "`curl -s $VMX | grep vmxAppBuilder | wc -l`" -eq 0 ]; then | |
echo Cannot find VMX at $VMX | |
echo Please edit the \$VMX variable | |
exit | |
fi | |
NAME=$1 | |
#URL=$2 | |
URL="data:image/jpeg;base64,"`base64 $2` | |
#Get the UUID for the desired model | |
UUID=`curl -s $VMX/model | jq -r '.data[] | select(.name=="'$NAME'") .uuid'` | |
if [ -z $UUID ]; then | |
echo "Cannot find model named" $NAME | |
echo "Available models:" `curl -s $VMX/model | jq -r '.data[] .name'` | |
exit | |
fi | |
#Check if we already have a session running with the desired model | |
SESSIONID=`curl -s $VMX/session | jq -r '.data[] | select(.model.name=="'$NAME'").id'` | |
if [ -z $SESSIONID ]; then | |
# Start a new session if we didn't find one | |
SESSIONID=`curl -s -X POST -d '{"uuids":["'$UUID'"]}' $VMX/session | jq -r .data.id` | |
fi | |
#Send the image to the session to return detections | |
curl -s -X POST -d '{"images":[{"image":"'$URL'"}]}' $VMX/session/$SESSIONID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment