lib.poly.vision
Tag 1
Image recognition api from http://aipoly.com, Identify food, animals and generic objects of any image with our new image recognition api
  Published by poly on Jul 13th 2017, 4:35 PM
  # Poly API Quickstart Guide ![alt](http://poly.ai/imagesforhosting/banner_categories_images.png) Your app will be able to identify a number of item categories, including general objects, food, animals, and plants. Below is a quick guide on best practice: ### Step 1: Create an account The API is accessibly through stdlib, if you don't already have an account head over to https://stdlib.com/ and register. After registering head to the [dashboard](https://dashboard.stdlib.com/dashboard/#/library-tokens) and note down your token under `Library Token`. ### Step 2: Making your first call Stdlib supports calls from various languages and through a simple REST api. In this quickstart guide we will show how to call the api from Python and REST (via curl). #### Python First install stdlib ``` $ pip install lib ``` The following snippet loads an image file, base64 encodes it before calling the Poly API. Category tells the api what we are looking for, see *Recognition Categories* for a comprehensive list. ```python from lib import lib import base64 with open(path_to_your_image, "rb") as f: encoded_img = base64.b64encode(f.read()) lib.poly.vision({ "category": "food", "image": '{{"_base64":"{}"}}'.format(encoded_img.decode('ascii')) }) ``` Poly API only requires the image resolution to be 256 x 256 px, higher resolution does not give better performance. Therefor it's best to resize the image before calling the API to reduce bandwidth usage. ```python from lib import lib from PIL import Image import base64 import io img = Image.open(path_to_your_image) img = img.resize((256,256)) buf = io.BytesIO() img.save(buf, "JPEG") base64img = base64.b64encode(buf.getvalue()) lib.poly.vision({ "category": "location", "image": '{{"_base64":"{}"}}'.format(base64img.decode('ascii')) }) ``` Example response: ```python {'results': [ {'label': 'hamburger', 'score': 44.8}, {'label': 'hotdog', 'score': 22.6}, {'label': 'chili_dog', 'score': 13.7}, {'label': 'cheeseburger', 'score': 13.4}, {'label': 'sloppy_joe', 'score': 2.9}] } ``` The score denotes how certain the API is on a scale of 0-100 of it's prediction. Note that the sum of all predictions can not exceed 100. #### REST The Poly API can be called through a simple POST request. * The image needs to be base64 encode. * Replace `<token here>` with the token from your dashboard. * `category` tells the api what we are looking for, see *Recognition Categories* for a comprehensive list. ```bash curl -X POST -H "Authorization: Bearer <token here>" \ -H "Content-Type: application/json" \ -d '{"category": "location", "image" : {"_base64":"'"$( base64 path/to/your/image.jpg)"'"}}' \ https://poly.lib.id/vision/ ``` Exampel response: ```json {"results":[ {"label":"restaurant","score":38.6}, {"label":"livingroom","score":19}, {"label":"foodmarket","score":10.1}, {"label":"diningroom","score":6.2}, {"label":"supermarket","score":3.2}] } ``` The score denotes how certain the API is on a scale of 0-100 of it's prediction. Note that the sum of all predictions can not exceed 100. ### Recognition Categories #### General ![alt](http://poly.ai/imagesforhosting/category_general.png) General is for common objects found indoors and outdoors. #### Food ![alt](http://poly.ai/imagesforhosting/category_food.png) Food identifies 1000 edible dishes from around the world. We can provide nutritional information upon request. #### Animal ![alt](http://poly.ai/imagesforhosting/category_animal.png) Animal identifies a growing number of animal species. Today it includes mammals, birds, and reptiles. Additional species available upon request. #### Plant ![alt](http://poly.ai/imagesforhosting/category_plant.png) Plant identifies a growing number of plant species. Flowers, shrubs, and notable tree leaves can be identified. Full trees are currently a challenge for computer vision to identify. #### Location ![alt](http://poly.ai/imagesforhosting/category_location.png) Location is for understanding what kind of room or area was a picture taken in, such as living room, garden, or inside a car. *More recognition categories will be added periodically. Contact us to* ### Best Image Properties #### Size For the fastest result, scale your image down to **224x224 pixels**. Larger sized images **will not** improve recognition accuracy. #### Object location Try centering the object in the picture frame, and make sure it covers at least a quarter of the area to be correctly identified. ![alt](http://poly.ai/imagesforhosting/coffee_cup.png) If you need to detect moving objects, or small objects in a picture for a use case in your business [contact us](http://aipoly.com/). #### Lighting and angle The Poly API is resistant to sharp changes in lighting and angles, so don't worry about colored lights or tilted images, the item in them should still be recognized. #### Camera quality As long as your camera's resolution is above 256 x 256, performance does not change significantly. You can identify photos taken by old smartphone cameras or modern DSLRs. ### Custom Object Recognition We train customized AI based on your image data requirements and allow you to run it both locally and as an API. If your company has an existing project which would benefit from cutting edge image recognition, [contact us](http://aipoly.com/).
# Poly API Quickstart Guide ![alt](http://poly.ai/imagesforhosting/banner_categories_images.png) Your app will be able to identify a number of item categories, including general objects, food, animals, and plants. Below is a quick guide on best practice: ### Step 1: Create an account The API is accessibly through stdlib, if you don't already have an account head over to https://stdlib.com/ and register. After registering head to the [dashboard](https://dashboard.stdlib.com/dashboard/#/library-tokens) and note down your token under `Library Token`. ### Step 2: Making your first call Stdlib supports calls from various languages and through a simple REST api. In this quickstart guide we will show how to call the api from Python and REST (via curl). #### Python First install stdlib ``` $ pip install lib ``` The following snippet loads an image file, base64 encodes it before calling the Poly API. Category tells the api what we are looking for, see *Recognition Categories* for a comprehensive list. ```python from lib import lib import base64 with open(path_to_your_image, "rb") as f: encoded_img = base64.b64encode(f.read()) lib.poly.vision({ "category": "food", "image": '{{"_base64":"{}"}}'.format(encoded_img.decode('ascii')) }) ``` Poly API only requires the image resolution to be 256 x 256 px, higher resolution does not give better performance. Therefor it's best to resize the image before calling the API to reduce bandwidth usage. ```python from lib import lib from PIL import Image import base64 import io img = Image.open(path_to_your_image) img = img.resize((256,256)) buf = io.BytesIO() img.save(buf, "JPEG") base64img = base64.b64encode(buf.getvalue()) lib.poly.vision({ "category": "location", "image": '{{"_base64":"{}"}}'.format(base64img.decode('ascii')) }) ``` Example response: ```python {'results': [ {'label': 'hamburger', 'score': 44.8}, {'label': 'hotdog', 'score': 22.6}, {'label': 'chili_dog', 'score': 13.7}, {'label': 'cheeseburger', 'score': 13.4}, {'label': 'sloppy_joe', 'score': 2.9}] } ``` The score denotes how certain the API is on a scale of 0-100 of it's prediction. Note that the sum of all predictions can not exceed 100. #### REST The Poly API can be called through a simple POST request. * The image needs to be base64 encode. * Replace `<token here>` with the token from your dashboard. * `category` tells the api what we are looking for, see *Recognition Categories* for a comprehensive list. ```bash curl -X POST -H "Authorization: Bearer <token here>" \ -H "Content-Type: application/json" \ -d '{"category": "location", "image" : {"_base64":"'"$( base64 path/to/your/image.jpg)"'"}}' \ https://poly.lib.id/vision/ ``` Exampel response: ```json {"results":[ {"label":"restaurant","score":38.6}, {"label":"livingroom","score":19}, {"label":"foodmarket","score":10.1}, {"label":"diningroom","score":6.2}, {"label":"supermarket","score":3.2}] } ``` The score denotes how certain the API is on a scale of 0-100 of it's prediction. Note that the sum of all predictions can not exceed 100. ### Recognition Categories #### General ![alt](http://poly.ai/imagesforhosting/category_general.png) General is for common objects found indoors and outdoors. #### Food ![alt](http://poly.ai/imagesforhosting/category_food.png) Food identifies 1000 edible dishes from around the world. We can provide nutritional information upon request. #### Animal ![alt](http://poly.ai/imagesforhosting/category_animal.png) Animal identifies a growing number of animal species. Today it includes mammals, birds, and reptiles. Additional species available upon request. #### Plant ![alt](http://poly.ai/imagesforhosting/category_plant.png) Plant identifies a growing number of plant species. Flowers, shrubs, and notable tree leaves can be identified. Full trees are currently a challenge for computer vision to identify. #### Location ![alt](http://poly.ai/imagesforhosting/category_location.png) Location is for understanding what kind of room or area was a picture taken in, such as living room, garden, or inside a car. *More recognition categories will be added periodically. Contact us to* ### Best Image Properties #### Size For the fastest result, scale your image down to **224x224 pixels**. Larger sized images **will not** improve recognition accuracy. #### Object location Try centering the object in the picture frame, and make sure it covers at least a quarter of the area to be correctly identified. ![alt](http://poly.ai/imagesforhosting/coffee_cup.png) If you need to detect moving objects, or small objects in a picture for a use case in your business [contact us](http://aipoly.com/). #### Lighting and angle The Poly API is resistant to sharp changes in lighting and angles, so don't worry about colored lights or tilted images, the item in them should still be recognized. #### Camera quality As long as your camera's resolution is above 256 x 256, performance does not change significantly. You can identify photos taken by old smartphone cameras or modern DSLRs. ### Custom Object Recognition We train customized AI based on your image data requirements and allow you to run it both locally and as an API. If your company has an existing project which would benefit from cutting edge image recognition, [contact us](http://aipoly.com/).
Identify items in images
  info
context
enabled
bg
info
pricing
$0.005 per auth request
rate limits
  parameters (click to modify)
{string}
category
= "food"
Which image classifier to use, valid values: food, animal, general
{buffer}
image
(required)
The image data to upload. For REST calls encode the image in base64.
  code