Create, Get, Update, Delete
Create Model
To create a model, you need to specify the model's name and other required fields (which depend on the model). Specifying the ID is optional.
Below, we create a classifier model with one initial concept. You can always add and remove concepts later.
import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;
// Insert here the initialization code as outlined on this page:
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
SingleModelResponse postModelsResponse = stub.postModels(
PostModelsRequest.newBuilder().addModels(
Model.newBuilder()
.setId("petsID")
.setOutputInfo(
OutputInfo.newBuilder().setData(
Data.newBuilder().addConcepts(Concept.newBuilder().setId("boscoe"))
)
)
).build()
);
if (postModelsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Post models failed, status: " + postModelsResponse.getStatus());// Insert here the initialization code as outlined on this page:
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
stub.PostModels(
{
models: [
{
id: "petsID",
output_info: {
data: {concepts: [{id: "boscoe"}]},
}
}
]
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("Post models failed, status: " + response.status.description);
}
}
);Add Concepts To A Model
You can add concepts to a model at any point. As you add concepts to inputs, you may want to add them to your model.
Remove Concepts From A Model
Conversely, if you'd like to remove concepts from a model, you can also do that.
Update Model Name and Configuration
Here we will change the model name to 'newname' and the model's configuration to have concepts_mutually_exclusive=true and closed_environment=true.
Get
List Model Types
Learn about available model types and their hyperparameters. This endpoint lists all the possible models that are creatable (when creatable=true), or in general in the platform (the others ones have creatable=false).
Get Models
To get a list of all models including models you've created as well as Clarifai models:
Get Model By Id
All models have unique Ids. You can get a specific model by its id:
Get Model Output Info By Id
The output info of a model lists what concepts it contains.
List Model Versions
Every time you train a model, it creates a new version. You can list all the versions created.
Get Model Version By Id
To get a specific model version, you must provide the model_id as well as the version_id. You can inspect the model version status to determine if your model is trained or still training.
Get Model Training Inputs
You can list all the inputs that were used to train the model.
Get Model Training Inputs By Version
You can also list all the inputs that were used to train a specific model version.
Delete A Model
You can delete a model using the model_id.
Delete A Model Version
You can also delete a specific version of a model with the model_id and version_id.
Delete All Models
If you would like to delete all models associated with an application, you can also do that. Please proceed with caution as these cannot be recovered.
Train A Model
When you train a model, you are telling the system to look at successfully indexed images with concepts you've provided and learn from them. This train operation is asynchronous. It may take a few seconds for your model to be fully trained and ready.
Note: you can repeat this operation as often as you like. By adding more images with concepts and training, you can get the model to predict exactly how you want it to.
Predict With A Model
Once you have trained a model you are ready to use your new model to get predictions. The predictions returned will only contain the concepts that you told it to see.
Search Models By Name And Type
You can search all your models by name and type of model.
Last updated
Was this helpful?