You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Create a Custom Vision Service REST API tutorial - Azure Cognitive Services | Microsoft Docs
2
+
title: Use the a Custom Vision Service REST API - Azure Cognitive Services | Microsoft Docs
3
3
description: Use the REST API to create, train, test, and export a custom vision model.
4
4
services: cognitive-services
5
5
author: blackmist
@@ -13,24 +13,25 @@ ms.author: larryfr
13
13
---
14
14
# Tutorial: Use the Custom Vision REST API
15
15
16
-
Learn how to use the Custom Vision REST API to create, train, score, and export a model.
16
+
Learn how to use the Custom Vision REST API to create, train, test, and export a model.
17
17
18
-
The information in this document demonstrates how to use a REST client to work with the REST API for training the Custom Vision service. The examples show how to use the API using the [curl]() utility from a bash environment, or Windows PowerShell.
18
+
The information in this document demonstrates how to use a REST client to work with the REST API for training the Custom Vision service. The examples show how to use the API using the `curl` utility from a bash environment and `Invoke-WebRequest` from Windows PowerShell.
19
19
20
20
> [!div class="checklist"]
21
21
> * Get keys
22
22
> * Create a project
23
23
> * Create tags
24
24
> * Add images
25
-
> * Use your own model
25
+
> * Train and test the model
26
+
> * Export the model
26
27
27
28
## Prerequisites
28
29
29
30
* A basic familiarity with Representational State Transfer (REST). This document does not go into details on things like HTTP verbs, JSON, or other things commonly used with REST.
30
31
31
-
* Either a bash (Bourne Again Shell) with the [curl]() utility or Windows PowerShell 3.0 (or greater).
32
+
* Either a bash (Bourne Again Shell) with the [curl](https://curl.haxx.se) utility or Windows PowerShell 3.0 (or greater).
32
33
33
-
*An Custom Vision account. For more information, see the [Build a classifier](getting-started-build-a-classifier.md) document.
34
+
*A Custom Vision account. For more information, see the [Build a classifier](getting-started-build-a-classifier.md) document.
34
35
35
36
## Get keys
36
37
@@ -97,7 +98,7 @@ For more information on this request, see [CreateProject](https://southcentralus
97
98
98
99
### Specific domains
99
100
100
-
To create a project for a specific domain, you can provide the __domain Id__ as an optional paramter. The following examples show how to retrieve a list of available domains:
101
+
To create a project for a specific domain, you can provide the __domain ID__ as an optional parameter. The following examples show how to retrieve a list of available domains:
101
102
102
103
```bash
103
104
curl -X GET "https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Training/domains" -H "Training-Key: $TRAININGKEY" --data-ascii ""
@@ -158,9 +159,7 @@ $resp.Content
158
159
159
160
## Create tags
160
161
161
-
When tagging images, you use a tag Id. To get a tag Id, you must create a tag or get the information for an existing tag.
162
-
163
-
The following example demonstrates how to create a new tag named `cat`. Replace `{projectId}` with the ID of your project. Use the `name=` parameter to specify the name of the tag:
162
+
To tag images, you must use a tag ID. The following example demonstrates how to create a new tag named `cat` and get a tag ID. Replace `{projectId}` with the ID of your project. Use the `name=` parameter to specify the name of the tag:
164
163
165
164
```bash
166
165
curl -X POST "https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Training/projects/{projectId}/tags?name=cat" -H "Training-Key: $TRAININGKEY" --data-ascii ""
Save the `id` value, as it is used when tagging images.
184
183
185
-
For more information on this requst, see [CreateTag](https://southcentralus.dev.cognitive.microsoft.com/docs/services/d0e77c63c39c4259a298830c15188310/operations/5a59953940d86a0f3c7a829d).
184
+
For more information on this request, see [CreateTag](https://southcentralus.dev.cognitive.microsoft.com/docs/services/d0e77c63c39c4259a298830c15188310/operations/5a59953940d86a0f3c7a829d).
The response to the request is similar to the following:
203
+
The response to the request is similar to the following JSON document:
205
204
206
205
```json
207
206
{
@@ -244,3 +243,139 @@ The response to the request is similar to the following:
244
243
245
244
For more information on this request, see [CreateImagesFromUrls](https://southcentralus.dev.cognitive.microsoft.com/docs/services/d0e77c63c39c4259a298830c15188310/operations/5a59953940d86a0f3c7a8287).
246
245
246
+
## Train the model
247
+
248
+
The following examples demonstrate how to train the model. Replace `{projectId}` with the ID of your project:
Save the `id` value, as it is used to test and export the model.
279
+
280
+
For more information, see [TrainProject](https://southcentralus.dev.cognitive.microsoft.com/docs/services/d0e77c63c39c4259a298830c15188310/operations/5a59953940d86a0f3c7a8294).
281
+
282
+
## Test the model
283
+
284
+
The following examples demonstrate how to perform a test of the model. Replace `{projectId}` with the ID of your project. Replace `{iterationId}` with the ID returned from training the model. Replace `https://linktotestimage` with the path to the test image.
For more information, see [QuickTestImageUrl](https://southcentralus.dev.cognitive.microsoft.com/docs/services/d0e77c63c39c4259a298830c15188310/operations/5a59953940d86a0f3c7a828d).
318
+
319
+
## Export the model
320
+
321
+
Exporting a model is a two-step process. First you must specify the model format, and then request the URL for the exported model.
322
+
323
+
### Request a model export
324
+
325
+
The following examples demonstrate how to export a `coreml` model. Replace `{projectId}` with the ID of your project. Replace `{iterationId}` with the ID returned from training the model.
The response to the request is similar to the following JSON document:
340
+
341
+
```json
342
+
{
343
+
"platform": "CoreML",
344
+
"status": "Exporting",
345
+
"downloadUri": null,
346
+
"flavor": null
347
+
}
348
+
```
349
+
350
+
For more information, see [ExportIteration](https://southcentralus.dev.cognitive.microsoft.com/docs/services/d0e77c63c39c4259a298830c15188310/operations/5a59953940d86a0f3c7a829b).
351
+
352
+
### Download the exported model
353
+
354
+
The following examples demonstrate how to retrieve the URL of the exported model. Replace `{projectId}` with the ID of your project. Replace `{iterationId}` with the ID returned from training the model.
The response to the request is similar to the following JSON document:
369
+
370
+
```json
371
+
[
372
+
{
373
+
"platform": "CoreML",
374
+
"status": "Done",
375
+
"downloadUri": "https://linktoexportedmodel",
376
+
"flavor": null
377
+
}
378
+
]
379
+
```
380
+
381
+
For more information, see [GetExports](https://southcentralus.dev.cognitive.microsoft.com/docs/services/d0e77c63c39c4259a298830c15188310/operations/5a59953940d86a0f3c7a829a).
0 commit comments