Skip to content

Label

PhotoTag is another PhotoILike service that allows you to label images according to the room they represent. Currently, PhotoTag can classify images among 23 different labels.

The rooms it detects are as follows

List of labels
Label Example
bathroom
Bathroom or toilet
Bathroom
bedroom
Bedroom
Bedroom
cert
Energy certificate document
Cert
commonzones
Common zones:
reception hall, entrance hall,
corridor, stairs, etc.
CommonZones
construction
Living quarters or dwelling under construction
or with construction elements
Construction
details
Close-up of objects
Detail
emptyroom
Empty room
Empty room
facade
Facade
Facade
kitchen
Kitchen
Kitchen
leisure
Leisure areas:
gymnasium, children's playground, etc.
Leisure
livingroom
Living room or lounge
Living room
map
Image of a map
Map
office
Office, office
or studio
Office
outdoors
Outdoor, garden, etc.
Outdoors
parking
Parking
Parking
plan
Floor plan
Plan
pool
Swimming pool
Pool
storage
Pantry, storeroom or
storage area
Storage
terrace
Terrace
Terrace
business
Business: cafeteria,
restaurant,
hairdresser,
supermarket, etc.
Business
corridor
Corridor
Corridor
seaviews
Sea view
SeaViews
unknown
This tag is used when
the image does not match
any of the other tags
in the list
Cat

Request

POST https://api.photoilike.com/v2.0/label

Headers

Fields

Key Value
Authorization string
Required
Session token preceded by the word Bearer.

Body of the request

The body of the request contains data with the following structure:

JSON representation

{
    "client-key": string,
    "image-url": string,
    "image-base64": string,
    "ext": string
}

Fields

Parameter Information
client-key string
Reqired
Client-key of the end user requesting the image score.
image-url string
Required1
URL that identifies from where the image to be processed can be obtained.
The image must be obtained through a GET request to the indicated URL.
image-base64 string
Required1
Base64 encoding of the image to be processed.
ext string
Required2
Extension of the file to use. The allowed values are: png, jpg, jpeg, webp, heic, avif.

Warning

1 Each request only processes one image, which implies that the image-url and image-base64 fields are disjoint, i.e., one or the other must be used, but never both at the same time.
2 If image-base64 is used, the ext parameter must be passed.

Response to the request

On success, the HTTP status code in the response header is 200 OK and the body of the response contains the precondition of the type of stay to which the image belongs. The precondition is an array of elements, where each element indicates the predicted label and the classification accuracy (value between 0 and 1).

JSON representation

{
    "id": string,
    "predictions": [
        {
            "label": string,
            "confidence": float
        },
        ...
    ] 
}

Fields

Parameter Information
id string
Identifier of the job that processed the request to get the image label.
predictions List
Array of label-confidence pairs.
predictions[item].label string
Indicates the label that the prediction obtains for the given image.
predictions[item].confidence float
Accuracy of the label that classified the service (value between 0 and 1).

Example of a request

curl --request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer {YOUR.SESSION.TOKEN}" \
--data '{"client-key": "{ACTIVE_CLIENT_KEY}", "image-url": "{https://example.org/photo.jpg}"}' \
https://api.photoilike.com/v2.0/label 
import requests

header = {
    # Add your token session
    'Authorization': 'Bearer YOUR.SESSION.TOKEN'
}

payload = {
    # Add an active client key
    'client-key': 'ACTIVE_CLIENT_KEY',
    # Add the image url you want to rate
    'image-url': 'https://example.org/photo.jpg'
}

endpoint = 'https://api.photoilike.com/v2.0/label'

# Make the request
r = requests.post(endpoint, headers=header, json=payload)

# Response in json format
response = r.json()
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import org.json.JSONObject;

public class Label {

    public static void main(String[] args) throws Exception {
        // add your session token
        String bearerToken = String.format("Bearer %s", "YOUR.SESSION.TOKEN");

        JSONObject payload = new JSONObject();
        // add an active client key
        payload.put("client-key", "ACTIVE_CLIENT_KEY");
        // add the image url you want to rate
        payload.put("image-url", "https://example.org/photo.jpg");


        String endpoint = "https://api.devel.photoilike.com/v2.0/label";

        // build the request
        HttpURLConnection connection = (HttpURLConnection) new URL(endpoint).openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Authorization", bearerToken);
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setDoOutput(true);

        OutputStream os = connection.getOutputStream();
        byte[] input = payload.toString().getBytes(StandardCharsets.UTF_8);
        os.write(input, 0, input.length);

        // make the request
        BufferedReader br = new BufferedReader(
                new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)
        );
        StringBuilder response = new StringBuilder();

        for (String responseLine = null; (responseLine = br.readLine()) != null; response.append(responseLine.trim()))
            ;

        // Response in json format
        JSONObject json = new JSONObject(response.toString());
    }

}
<?php

  // Add your token session
  $headers = array(
    'Content-Type:application/json',
    'Authorization: Bearer YOUR.SESSION.TOKEN'
  );

  // Add an active client key
  // Add the image url you want to label
  $payload = json_encode(array(
    'client-key' => 'ACTIVE_CLIENT_KEY',
    'image-url' => 'https://example.org/photo.jpg'
  ));

  $endpoint = "https://api.photoilike.com/v2.0/label";

  $ch = curl_init($endpoint);
  curl_setopt($ch,  CURLOPT_POSTFIELDS, $payload);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  // Make the request
  $result = curl_exec($ch);

  curl_close($ch);

  // Response in json format
  $response = json_decode($result);
 ?>