Version 1.9.72 (Release Notes)


tagimghttps://api.pixlab.io/tagimg

Description

Generates a description of an image in human readable language with complete sentences. The description is based on the visual content as reported by our state-of-the-art image labeling algorithm. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English.

HTTP Methods

GET, POST

Request Parameters

Required

FieldsTypeDescription
imgURLInput media URL. If you want to upload your image directly from your app, then submit a multipart/form-data POST request.
keyStringYour PixLab API Key. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to.

POST Request Body (If you plan to use POST instead of a simple GET request)

Allowed Content-Type:

multipart/form-data
application/json

Use multipart/form-data if you want to upload your media file directly (refer to the sample set for a working example). If you are using JSON, then the media file must be already uploaded somewhere. Call store if you want to upload an image for example before invoking this endpoint.

Response

application/json

This command always return a JSON object after each call. The field of interest here is the tags array which hold name & confidence values for each returned tag. The following are the JSON fields returned in response body:

FieldsTypeDescription
statusIntegerStatus code 200 indicates success, any other code indicates failure.
tagsArrayJSON array holding name & confidence values of the current tag (See example below).
errorStringError message if status != 200.

Python Example

import requests
import json

# Tag an image based on detected visual content which mean running a CNN on top of it.
# https://pixlab.io/cmd?id=tagimg for more info.

# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the sample set for more info.
img = 'https://s-media-cache-ak0.pinimg.com/originals/35/d0/f6/35d0f6ee0e40306c41cfd714c625f78e.jpg' 
# Your PixLab key
key = 'My_PixLab_Key'

req = requests.get('https://api.pixlab.io/tagimg',params={'img':img,'key':key})
reply = req.json()
if reply['status'] != 200:
	print (reply['error'])
else:
    total = len(reply['tags']) # Total tags
    print ("Total tags: "+str(total))
    for tag in reply['tags']:
		print("Tag: "+tag['name']+" - Confidence: "+str(tag['confidence']))

See Also