Skip to content

Pretrained classifiers

Nyckel offers a variety of Pretrained Classifiers for different use cases. These classifiers are trained and maintained by Nyckel, and ready for you to use.

Setup

Classify text

import nyckel
function_id = 'toxic-language-identifier'
text = 'Hello friend!'
credentials = nyckel.Credentials(client_id, client_secret)
nyckel.invoke(function_id, text, credentials)
{
    'labelName': 'Not Offensive', 
    'labelId': 'label_3e46tk7jimpeozap', 
    'confidence': 0.9990668684599706
}

Classify image

For image classification functions, use a URL or base64 encoded image as the input. Like so:

import nyckel
function_id = 'colors-identifier'
image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Altja_j%C3%B5gi_Lahemaal.jpg/320px-Altja_j%C3%B5gi_Lahemaal.jpg"
credentials = nyckel.Credentials(client_id, client_secret)
nyckel.invoke(function_id, image_url, credentials)
{
    'labelName': 'Green',
    'labelId': 'label_csyoeshimzojn8xs',
    'confidence': 0.6614829725975897
}

Reference

nyckel.invoke

invoke(function_id: str, data: str, credentials: Credentials) -> Dict
Source code in src/nyckel/functions/pretrained.py
6
7
8
9
def invoke(function_id: str, data: str, credentials: Credentials) -> Dict:
    session = credentials.get_session()
    endpoint = f"https://www.nyckel.com/v1/functions/{function_id}/invoke"
    return session.post(endpoint, json={"data": data}).json()