Create a training
POST
/v1/models/{model_owner}/{model_name}/versions/{version_id}/trainingsStart a new training of the model version you specify.
Example request body:
{
"destination": "{new_owner}/{new_name}",
"input": {
"train_data": "https://example.com/my-input-images.zip",
},
"webhook": "https://example.com/my-webhook",
}
Example cURL request:
curl -s -X POST \
-d '{"destination": "{new_owner}/{new_name}", "input": {"input_images": "https://example.com/my-input-images.zip"}}' \
-H "Authorization: Token <paste-your-token-here>" \
-H 'Content-Type: application/json' \
https://api.replicate.com/v1/models/stability-ai/sdxl/versions/da77bc59ee60423279fd632efb4795ab731d9e3ca9705ef3341091fb989b7eaf/trainings
The response will be the training object:
{
"id": "zz4ibbonubfz7carwiefibzgga",
"model": "stability-ai/sdxl",
"version": "da77bc59ee60423279fd632efb4795ab731d9e3ca9705ef3341091fb989b7eaf",
"input": {
"input_images": "https://example.com/my-input-images.zip"
},
"logs": "",
"error": null,
"status": "starting",
"created_at": "2023-09-08T16:32:56.990893084Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/zz4ibbonubfz7carwiefibzgga/cancel",
"get": "https://api.replicate.com/v1/predictions/zz4ibbonubfz7carwiefibzgga"
}
}
As models can take several minutes or more to train, the result will not be available immediately. To get the final result of the training you should either provide a webhook
HTTPS URL for us to call when the results are ready, or poll the get a training endpoint until it has finished.
When a training completes, it creates a new version of the model at the specified destination.
To find some models to train on, check out the trainable language models collection.
请求参数
The name of the user or organization that owns the model.
The name of the model.
The ID of the version.
A string representing the desired model to push to in the format {destination_model_owner}/{destination_model_name}
. This should be an existing model owned by the user or organization making the API request. If the destination is invalid, the server will return an appropriate 4XX response.
An object containing inputs to the Cog model's train()
function.
An HTTPS URL for receiving a webhook when the training completes. The webhook will be a POST request where the request body is the same as the response body of the get training operation. If there are network problems, we will retry the webhook a few times, so make sure it can be safely called more than once.
{
"destination": "string",
"input": {},
"webhook": "string"
}
示例代码
Responses
{}