Share via


Images - Create From Files

This API accepts a batch of files, and optionally tags, to create training images. There is a limit of 64 images and 20 tags. If all images are successful created, 200(OK) status code will be returned. Otherwise, 207 (Multi-Status) status code will be returned and detail status for each image will be listed in the response payload.

POST {Endpoint}/customvision/v3.3/training/projects/{projectId}/images/files

URI Parameters

Name In Required Type Description
Endpoint
path True

string

Supported Cognitive Services endpoints.

projectId
path True

string (uuid)

The project id.

Request Header

Media Types: "application/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"

Name Required Type Description
Training-Key True

string

Request Body

Media Types: "application/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"

Name Type Description
images

ImageFileCreateEntry[]

metadata

object

The metadata of image. Limited to 50 key-value pairs per image. The length of key is limited to 256. The length of value is limited to 512.

tagIds

string[] (uuid)

Responses

Name Type Description
200 OK

ImageCreateSummary

OK

Media Types: "application/json", "application/xml", "text/xml"

Other Status Codes

ImageCreateSummary

207

Media Types: "application/json", "application/xml", "text/xml"

Other Status Codes

CustomVisionError

Error response

Media Types: "application/json", "application/xml", "text/xml"

Security

Training-Key

Type: apiKey
In: header

Examples

Successful CreateImagesFromFiles request

Sample request

POST https://westus.api.cognitive.microsoft.com/customvision/v3.3/training/projects/64b822c5-8082-4b36-a426-27225f4aa18c/images/files


{
  "images": [
    {
      "name": "hemlock_10.jpg",
      "contents": ""
    }
  ],
  "tagIds": [
    "b607964f-7bd6-4a3b-a869-6791fb6aab87"
  ]
}

Sample response

{
  "isBatchSuccessful": true,
  "images": [
    {
      "sourceUrl": "\"hemlock_10.jpg\"",
      "status": "OK",
      "image": {
        "id": "4d6eb844-42ee-42bc-bd6f-c32455ef07c9",
        "created": "2017-12-19T15:56:10Z",
        "width": 1095,
        "height": 900,
        "resizedImageUri": "{Resized Image Uri}",
        "originalImageUri": "{Image Uri}",
        "thumbnailUri": "{Thumbnail Uri}",
        "tags": [
          {
            "tagId": "b607964f-7bd6-4a3b-a869-6791fb6aab87",
            "created": "2017-12-19T15:56:09Z",
            "tagName": "tag 1"
          }
        ]
      }
    }
  ]
}
{
  "isBatchSuccessful": false,
  "images": [
    {
      "sourceUrl": "\"hemlock_10.jpg\"",
      "status": "OK",
      "image": {
        "id": "4d6eb844-42ee-42bc-bd6f-c32455ef07c9",
        "created": "2017-12-19T15:56:10Z",
        "width": 1095,
        "height": 900,
        "resizedImageUri": "{Resized Image Uri}",
        "originalImageUri": "{Image Uri}",
        "thumbnailUri": "{Thumbnail Uri}",
        "tags": [
          {
            "tagId": "b607964f-7bd6-4a3b-a869-6791fb6aab87",
            "created": "2017-12-19T15:56:09Z",
            "tagName": "tag 1"
          }
        ]
      }
    },
    {
      "sourceUrl": "{url}",
      "status": "ErrorLimitExceed"
    }
  ]
}

Definitions

Name Description
CustomVisionError
CustomVisionErrorCodes

The error code.

Image

Image model to be sent as JSON.

ImageCreateResult
ImageCreateStatus

Status of the image creation.

ImageCreateSummary
ImageFileCreateBatch
ImageFileCreateEntry
ImageRegion
ImageTag
Region

CustomVisionError

Name Type Description
code

CustomVisionErrorCodes

The error code.

message

string

A message explaining the error reported by the service.

CustomVisionErrorCodes

The error code.

Value Description
NoError
BadRequest
BadRequestExceededBatchSize
BadRequestNotSupported
BadRequestInvalidIds
BadRequestProjectName
BadRequestProjectNameNotUnique
BadRequestProjectDescription
BadRequestProjectUnknownDomain
BadRequestProjectUnknownClassification
BadRequestProjectUnsupportedDomainTypeChange
BadRequestProjectUnsupportedExportPlatform
BadRequestProjectImagePreprocessingSettings
BadRequestProjectDuplicated
BadRequestIterationName
BadRequestIterationNameNotUnique
BadRequestIterationDescription
BadRequestIterationIsNotTrained
BadRequestIterationValidationFailed
BadRequestWorkspaceCannotBeModified
BadRequestWorkspaceNotDeletable
BadRequestTagName
BadRequestTagNameNotUnique
BadRequestTagDescription
BadRequestTagType
BadRequestMultipleNegativeTag
BadRequestMultipleGeneralProductTag
BadRequestImageTags
BadRequestImageRegions
BadRequestNegativeAndRegularTagOnSameImage
BadRequestUnsupportedDomain
BadRequestRequiredParamIsNull
BadRequestIterationIsPublished
BadRequestInvalidPublishName
BadRequestInvalidPublishTarget
BadRequestUnpublishFailed
BadRequestIterationNotPublished
BadRequestSubscriptionApi
BadRequestExceedProjectLimit
BadRequestExceedIterationPerProjectLimit
BadRequestExceedTagPerProjectLimit
BadRequestExceedTagPerImageLimit
BadRequestExceededQuota
BadRequestCannotMigrateProjectWithName
BadRequestNotLimitedTrial
BadRequestImageBatch
BadRequestImageStream
BadRequestImageUrl
BadRequestImageFormat
BadRequestImageSizeBytes
BadRequestImageDimensions
BadRequestImageExceededCount
BadRequestTrainingNotNeeded
BadRequestTrainingNotNeededButTrainingPipelineUpdated
BadRequestTrainingValidationFailed
BadRequestClassificationTrainingValidationFailed
BadRequestMultiClassClassificationTrainingValidationFailed
BadRequestMultiLabelClassificationTrainingValidationFailed
BadRequestDetectionTrainingValidationFailed
BadRequestTrainingAlreadyInProgress
BadRequestDetectionTrainingNotAllowNegativeTag
BadRequestInvalidEmailAddress
BadRequestDomainNotSupportedForAdvancedTraining
BadRequestExportPlatformNotSupportedForAdvancedTraining
BadRequestReservedBudgetInHoursNotEnoughForAdvancedTraining
BadRequestExportValidationFailed
BadRequestExportAlreadyInProgress
BadRequestPredictionIdsMissing
BadRequestPredictionIdsExceededCount
BadRequestPredictionTagsExceededCount
BadRequestPredictionResultsExceededCount
BadRequestPredictionInvalidApplicationName
BadRequestPredictionInvalidQueryParameters
BadRequestInvalidImportToken
BadRequestExportWhileTraining
BadRequestImageMetadataKey
BadRequestImageMetadataValue
BadRequestOperationNotSupported
BadRequestInvalidArtifactUri
BadRequestCustomerManagedKeyRevoked
BadRequestInvalid
UnsupportedMediaType
Forbidden
ForbiddenUser
ForbiddenUserResource
ForbiddenUserSignupDisabled
ForbiddenUserSignupAllowanceExceeded
ForbiddenUserDoesNotExist
ForbiddenUserDisabled
ForbiddenUserInsufficientCapability
ForbiddenDRModeEnabled
ForbiddenInvalid
NotFound
NotFoundProject
NotFoundProjectDefaultIteration
NotFoundIteration
NotFoundIterationPerformance
NotFoundTag
NotFoundImage
NotFoundDomain
NotFoundApimSubscription
NotFoundInvalid
Conflict
ConflictInvalid
ErrorUnknown
ErrorIterationCopyFailed
ErrorPreparePerformanceMigrationFailed
ErrorProjectInvalidWorkspace
ErrorProjectInvalidPipelineConfiguration
ErrorProjectInvalidDomain
ErrorProjectTrainingRequestFailed
ErrorProjectImportRequestFailed
ErrorProjectExportRequestFailed
ErrorFeaturizationServiceUnavailable
ErrorFeaturizationQueueTimeout
ErrorFeaturizationInvalidFeaturizer
ErrorFeaturizationAugmentationUnavailable
ErrorFeaturizationUnrecognizedJob
ErrorFeaturizationAugmentationError
ErrorExporterInvalidPlatform
ErrorExporterInvalidFeaturizer
ErrorExporterInvalidClassifier
ErrorPredictionServiceUnavailable
ErrorPredictionModelNotFound
ErrorPredictionModelNotCached
ErrorPrediction
ErrorPredictionStorage
ErrorRegionProposal
ErrorUnknownBaseModel
ErrorInvalid

Image

Image model to be sent as JSON.

Name Type Description
created

string (date-time)

Date the image was created.

height

integer (int32)

Height of the image.

id

string (uuid)

Id of the image.

metadata

object

Metadata associated with this image.

originalImageUri

string

The URI to the original uploaded image. If VNET feature is enabled this will be a relative path to be used with GetArtifact, otherwise this will be an absolute URI to the resource.

regions

ImageRegion[]

Regions associated with this image.

resizedImageUri

string

The URI to the (resized) image used for training. If VNET feature is enabled this will be a relative path to be used with GetArtifact, otherwise this will be an absolute URI to the resource.

tags

ImageTag[]

Tags associated with this image.

thumbnailUri

string

The URI to the thumbnail of the original image. If VNET feature is enabled this will be a relative path to be used with GetArtifact, otherwise this will be an absolute URI to the resource.

width

integer (int32)

Width of the image.

ImageCreateResult

Name Type Description
image

Image

The image.

sourceUrl

string

Source URL of the image.

status

ImageCreateStatus

Status of the image creation.

ImageCreateStatus

Status of the image creation.

Value Description
OK
OKDuplicate
ErrorSource
ErrorImageFormat
ErrorImageSize
ErrorStorage
ErrorLimitExceed
ErrorTagLimitExceed
ErrorRegionLimitExceed
ErrorUnknown
ErrorNegativeAndRegularTagOnSameImage

ImageCreateSummary

Name Type Description
images

ImageCreateResult[]

List of the image creation results.

isBatchSuccessful

boolean

True if all of the images in the batch were created successfully, otherwise false.

ImageFileCreateBatch

Name Type Description
images

ImageFileCreateEntry[]

metadata

object

The metadata of image. Limited to 50 key-value pairs per image. The length of key is limited to 256. The length of value is limited to 512.

tagIds

string[] (uuid)

ImageFileCreateEntry

Name Type Description
contents

string (byte)

name

string

regions

Region[]

tagIds

string[] (uuid)

ImageRegion

Name Type Description
created

string (date-time)

height

number (float)

Height.

left

number (float)

Coordinate of the left boundary.

regionId

string (uuid)

tagId

string (uuid)

Id of the tag associated with this region.

tagName

string

top

number (float)

Coordinate of the top boundary.

width

number (float)

Width.

ImageTag

Name Type Description
created

string (date-time)

tagId

string (uuid)

tagName

string

Region

Name Type Description
height

number (float)

Height.

left

number (float)

Coordinate of the left boundary.

tagId

string (uuid)

Id of the tag associated with this region.

top

number (float)

Coordinate of the top boundary.

width

number (float)

Width.