Now you can accelerate your computer vision deployments by taking advantage of the Chooch computer vision API. Each imaging system captures its own images or videos, and then sends them to a hosted inference engine running AI models. Using Chooch’s computer vision API, these two systems can establish a standard protocol for communication. The host machine then takes the input image or video, runs it through the model, and sends the results back to the requester within a fraction of a second.
import requests
import base64
import io
from PIL import Image
import json
image = Image.open("your_local_image").convert("RGB")
# Convert to a JPEG Buffer
buffered = io.BytesIO()
image.save(buffered, quality=90, format="JPEG")
# Base 64 Encode
base64_string = base64.b64encode(buffered.getvalue())
base64_string = base64_string.decode("ascii")
payload = { "base64str": base64_string, "model_id": '7f0829c0-fe45-4417-a8a0-1fb2c0b62d6d', "conf_thresh": 0.4, "nms_thresh": 0.45 }
api_url = 'https://apiv2.chooch.ai/predict?api_key=dd325728-54c0-45fc-82ad-b4ed037adcfd'
response = requests.put(api_url, data=json.dumps(payload))
json_data = json.loads(response.content)
print(json_data)
const response = new XMLHttpRequest();
let base64String = "";
const fileInput = document.querySelector('input');
fileInput.addEventListener('change', (e) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onloadend = () => {
base64String = reader.result;
};
reader.readAsDataURL(file);
});
const json = JSON.stringify({ base64str: base64String, model_id: '7f0829c0-fe45-4417-a8a0-1fb2c0b62d6d', conf_thresh: 0.4, nms_thresh: 0.45 });
response.open("PUT", 'https://apiv2.chooch.ai/predict?api_key=dd325728-54c0-45fc-82ad-b4ed037adcfd')
response.setRequestHeader('Content-Type', 'application/json');
response.send(json);
response.onload = (e) => { alert(response.response); }
curl -d '{"base64str": base64_string, "model_id": "7f0829c0-fe45-4417-a8a0-1fb2c0b62d6d", "conf_thresh": 0.4, "nms_thresh": 0.45}' -H "Content-Type: application/json" -X PUT https://apiv2.chooch.ai/predict?api_key=dd325728-54c0-45fc-82ad-b4ed037adcfd
The response fields are:
The Chooch API is organized around REST. The API recognizes objects and concepts in videos and images from our pre-trained models.
The API is compatible with livestreams and live tagging.
The image recognition API is a straightforward REST API conducting classification and object detection predictions on images. The image URL is passed as a field to the API and the API returns a JSON based response with relevant predictions.
# Image Recognition with Local Image
import requests
import json
url = 'https://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'
files = {'image': open('local_image.jpg', 'rb')}
response = requests.post(url, files=files)
print(response.content)
curl --location --request POST "https://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19" --form "image=@local_image.jpg"
# Image Recognition with Image Url
import requests
import json
url = 'https://api.chooch.ai/predict/image?url=https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'
response = requests.post(url)
print(response.content)
curl --location --request GET "https://api.chooch.ai/predict/image?url=https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19" --header "Content-Type: application/json"
API input fields are:
The sample JSON response is:
The response fields are:
The FTP drop function was developed on top of the Chooch API for image and video professionals who want to tag their images and videos autonomously. For every client a personal FTP host is issued together with the API.
The FTP drop sends the image to the API. The API predicts the image and places the results in the keywords field of the IPTC metadata file. Once the metadata has been successfully placed into the keywords fields of the IPTC file, it is sent to the destination directed by the user.
# Image Recognition with Local Image
import requests
import json
url = 'https://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19&model_id=808'
files = {'image': open('local_image.jpg', 'rb')}
response = requests.post(url, files=files)
print(response.content)
curl --location --request POST "https://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19&model_id=808" --form "image=@local_image.jpg"
# Image Recognition with Image Url
import requests
import json
url = 'https://api.chooch.ai/predict/image?url=https://chooch-share.s3.amazonaws.com/cat.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19&model_id=808'
response = requests.post(url)
print(response.content)
curl --location --request GET "https://api.chooch.ai/predict/image?url=https://chooch-share.s3.amazonaws.com/cat.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19&model_id=808" --header "Content-Type: application/json"
API input fields are:
The sample JSON response is:
{
"status": "ok",
"model_id": "808",
"url": "https://chooch-share.s3.amazonaws.com/cat.jpg",
"predictions": [
{
"class_title": "cat",
"order": 1
}
],
"prediction_type": "image"
}
The response fields are:
# Object Detection with Image Url
import requests
import json
url = 'https://api.chooch.ai/predict/object_detection/?url=https://choochdashboard.s3.amazonaws.com/truck.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19c&model_id=777'
response = requests.post(url)
json_data = json.loads(response.content)
print(json_data)
curl --location --request GET "https://api.chooch.ai/predict/object_detection/?url=https://choochdashboard.s3.amazonaws.com/truck.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19c&model_id=777"
import requests
import json
import time
url = 'https://api.chooch.ai/predict/object_detection/?model_id=777&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'
files = {'image': open('local_image.jpg', 'rb')}
response = requests.post(url, files=files)
json_data = json.loads(response.content)
print(json_data)
curl --location --request POST "https://api.chooch.ai/predict/object_detection/?model_id=777&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19" --form "image=@local_image.jpg"
{
"status": "ok",
"prediction_type": "object_detection",
"predictions": [
{
"class_title": "person",
"model_id": 777,
"score": 0.74613,
"coordinates": {
"xmin": 0,
"ymin": 35,
"ymax": 297,
"xmax": 179
}
}
]
}
API input fields are:
Chooch Face Recognition consists of Perception > People > Images
You can search and tag a face in the Chooch API by feeding the Chooch API a Face Image. Below is a sample post of an image url.
The fields are:
You can also post an image through the image field. Below are 2 separate sample posts in python.
import requests
import json
import time
url = 'https://api.chooch.ai/predict/face?url=https://choochdashboard.s3.amazonaws.com/base_site/1461123713-esq050116cover001s.jpg&person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'
response = requests.post(url)
json_data = json.loads(response.content)
print(json_data)
curl --location --request POST "https://api.chooch.ai/predict/face?url=https://choochdashboard.s3.amazonaws.com/base_site/1461123713-esq050116cover001s.jpg&person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19"
import requests
import json
import time
url = 'https://api.chooch.ai/predict/face?person_id_filter=-1&model_id=5&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'
files = {'image': open('local_image.jpg', 'rb')}
response = requests.post(url, files=files)
json_data = json.loads(response.content)
print(json_data)
curl --location --request POST "https://api.chooch.ai/predict/face?person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19" --form "image=@local_image.jpg"
The example JSON response is here below. In this example, the similarity is 0.80. The face_recog_hit is True when there is a match and False when there is no match.
This API function allows the user to add a face image with a unique id (it can be a unique person name, or a unique id assigned to a person):
import requests
import json
import time
url = 'https://api.chooch.ai/predict/face?&key_id=3245&model_id=7&command=insert_person_image_key_id&apikey=46g5717-1sd3-35h6-9104-b8h5c819dn19'
files = {'image': open('/home/ashwmadhu/Desktop/12.jpg', 'rb')}
response = requests.post(url, files=files)
json_data = json.loads(response.content)
print(json_data)
curl -X POST 'https://api.chooch.ai/predict/face?key_id=3245&model_id=7&command=insert_person_image_key_id&apikey=46g5717-1sd3-35h6-9104-b8h5c819dn19' -F image=@/home/ashwmadhu/Desktop/12.jpg
{
"status_description":"success",
"post_type":"insert_person_image",
"status":41868
}
You can create a person through the Chooch API. Below is a sample Python based usage of the create_person command.
# Create Person Python Code
import requests
import json
url = 'https://api.chooch.ai/predict/face?person_name=Tom Bill&model_id=5&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=create_person'
response = requests.post(url)
json_data = json.loads(response.content)
print(json_data)
curl --location --request POST "https://api.chooch.ai/predict/face?person_name=Tom%20Bill&model_id=5&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=create_person"
{
person_id: 37,
status: 37,
status_description: success,
post_type: create_person
}
A face image can be added to an existing person using the person_id. Below is a sample Python based usage of the insert_person_image command.
# Add face image to person with person_id_filter (person_id) Python Code
import requests
import json
url = 'https://api.chooch.ai/predict/face?person_id_filter=37&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=insert_person_image'
files = {'image': open('your_image.jpg', 'rb')}
response = requests.post(url, files=files)
json_data = json.loads(response.content)
print(json_data)
curl --location --request POST "https://api.chooch.ai/predict/face?person_id_filter=37&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=insert_person_image" --form "image=@"
{
status: 210,
status_description: success,
post_type: insert_person_image
}
Thank you for evaluating the Chooch AI computer vision API.
Learn more about Chooch AI.