Create, get and update
Create Model
You can create your own model and train it with your own images and concepts. Once you train it to see how you would like it to see, you can then use that model to make predictions.
When you create a model you give it a name and an id. If you don't supply an id, one will be created for you.
app.models.create("petsID").then(
function(response) {
// do something with response
},
function(err) {
// there was an error
}
);from clarifai.rest import ClarifaiApp
app = ClarifaiApp(api_key='YOUR_API_KEY')
app.models.create('petsID')client.createModel("petsID").executeSync();using System.Threading.Tasks;
using Clarifai.API;
namespace YourNamespace
{
public class YourClassName
{
public static async Task Main()
{
var client = new ClarifaiClient("YOUR_API_KEY");
await client.CreateModel("petsID")
.ExecuteAsync();
}
}
}Create Model With Concepts
You can also create a model and initialize it with the concepts it will contain. You can always add and remove concepts later.
app.models.create(
"petsID",
[
{ "id": "boscoe" }
]
).then(
function(response) {
// do something with response
},
function(err) {
// there was an error
}
);from clarifai.rest import ClarifaiApp
app = ClarifaiApp(api_key='YOUR_API_KEY')
model = app.models.create('petsID', concepts=['boscoe'])client.createModel("petsID")
.withOutputInfo(ConceptOutputInfo.forConcepts(
Concept.forID("boscoe")
))
.executeSync();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 Concept Name
The code below showcases how to update a concept's name given its id.
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 Models
To get a list of all models including models you've created as well as public 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 all the 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?