Although PSI services communicate using JSON, they can also support non-JSON data by the use of “rich values”, which are “http” or “data” URIs that either refer to a resource with a non-JSON representation or which directly encode a non-JSON value as a data URI. The PSI schema for these values has the form @media-type.

Consider if Sir Ronald Fisher had taken colour photographs of the 150 irises represented in the Iris relation, and that those images were accessible in this example service via the attribute at http://example.org/data/iris/image. Inspecting it reveals that it emits JPEG images:

GET http://example.org/data/iris/image
200 OK
{
    "psiType":     "attribute",
    "uri":         "http://example.org/data/iris/image",
    "relation":    "http://example.org/data/iris",
    "emits":       "@image/jpeg",
    "querySchema": { ... }
}

Requesting the image of the first instance in the Iris relation at http://example.org produces a data URI-encoded JPEG image (in which the ellipsis indicates the 26,500 character URI has been truncated):

GET http://example.org/data/iris/image?instance=1
200 OK
{
    "psiType": "value",
    "value":   "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA..."
}

The list of learners retrieved earlier included the following:

GET http://example.org/learn/imageclass
200 OK
{
    "psiType":        "learner",
    "uri":            "http://example.org/learn/imageclass",
    "description":    "Supervised classifier of JPEG images using colour and shape information",
    "taskSchema":    {
        "/resources": {
            "/target":   { "$nominalAttribute": { "allItems": "$string" },
            "/source":   { "$richValueAttribute": { "mediaType": "image/jpeg" } }
        }
    }
}

As the image-producing attribute emits rich values that are JPEG images it is suitable for use in training with the imageclass classifier. Training a predictor proceeds in the same manner as the knn example. Examining the produced predictor:

GET http://example.org/infer/imageclass_iris_20130816100025432
200 OK
{
    "psiType":      "transformer",
    "uri":          "http://example.org/infer/imageclass_iris_20130816100025432",
    "description":  "Image classifier (trained on iris)",
    "accepts":      "@image/jpeg",
    "emits":        { "$string" { "enum": [ "setosa", "versicolor", "virginica" ] } },
    "provenance":   {
        "learner":    "http://example.org/learn/imageclass",
        "task":        {
            "resources": {
                "source": "$http://example.org/data/iris/image",
                "target": "$http://example.org/data/iris/flower/species"
            }
        },
        "created":    "2013-08-16T00:00Z"
    }
}

Prediction on JPEG images of iris flowers is now possible, either by providing the encoded image directly in a data URI or indirectly via its HTTP URI:

GET http://example.org/infer/imageclass_iris_20130816100025432?value=http://upload.wikimedia.org/wikipedia/commons/5/56/Kosaciec_szczecinkowaty_Iris_setosa.jpg
200 OK
{
    "psiType":  "result",
    "value":    "setosa"
}

Next steps

Try out many of the examples you’ve just seen with our demonstration service at http://poseidon.cecs.anu.edu.au, perhaps assisted by the demonstration client.

Implement a service or client for yourself, using the source for our demonstrations as a starting point: https://github.com/psi-project

Adapting a predictor to a new relation