add_images {AzureVision}R Documentation

Add, list and remove images for a project


Add, list and remove images for a project


add_images(project, ...)

## S3 method for class 'classification_project'
add_images(project, images, tags = NULL, ...)

## S3 method for class 'object_detection_project'
add_images(project, images, regions = NULL, ...)

list_images(project, include = c("all", "tagged", "untagged"),
  as = c("ids", "dataframe", "list"), iteration = NULL)

remove_images(project, image_ids = list_images(project, "untagged", as =
  "ids"), confirm = TRUE)



A Custom Vision project.


Arguments passed to lower-level functions.


For add_images, the images to add (upload) to the project.


Optional tags to add to the images. Only for classification projects.


Optional list of regions in the images that contain objects. Only for object detection projects.


For list_images, which images to include in the list: untagged, tagged, or both (the default).


For list_images, the return value: a vector of image IDs, a data frame of image metadata, or a list of metadata.


For list_images, the iteration ID (roughly, which model generation to use). Defaults to the latest iteration.


For remove_images, the IDs of the images to remove from the project.


For remove_images, whether to ask for confirmation first.


The images to be uploaded can be specified as:

Uploaded images can also have tags added (for a classification project) or regions (for an object detection project). Classification tags can be specified in the following ways:

If the length of the vector is 1, it will be recycled to the length of image_ids.

Object detection projects also have tags, but they are specified as part of the regions argument. The regions to add should be specified as a list of data frames, with one data frame per image. Each data frame should have one row per region, and the following columns:

Any other columns in the data frame will be ignored. If the length of the list is 1, it will be recycled to the length of image_ids.

Note that once uploaded, images are identified only by their ID; there is no general link back to the source filename or URL. If you don't include tags or regions in the add_images call, be sure to save the returned IDs and then call add_image_tags or add_image_regions as appropriate.


For add_images, the vector of IDs of the uploaded images.

For list_images, based on the value of the as argument. The default is a vector of image IDs; as="list" returns a (nested) list of image metadata with one component per image; and as="dataframe" returns the same metadata but reshaped into a data frame.

See Also

add_image_tags and add_image_regions to add tags and regions to images, if not done at upload time

add_tags, list_tags, remove_tags



## Not run: 

endp <- customvision_training_endpoint(url="endpoint_url", key="key")

# classification
proj1 <- create_classification_project(endp, "myproject")
imgs <- dir("path/to/images", full.names=TRUE)

# recycling: apply one tag to all images
add_images(proj1, imgs, tags="mytag")
list_images(proj1, include="tagged", as="dataframe")

# different tags per image
add_images(proj1, c("cat.jpg", "dog.jpg", tags=c("cat", "dog"))

# adding online images
host <- ""
img_urls <- paste0(host, c("img1.jpg", "img2.jpg", "img3.jpg"))
add_images(proj1, img_urls, tags="mytag")

# multiple label classification
proj2 <- create_classification_project(endp, "mymultilabelproject", multiple_tags=TRUE)

add_images(proj2, imgs, tags=list(c("tag1", "tag2")))
add_images(proj2, c("catanddog.jpg", "cat.jpg", "dog.jpg"),
        c("cat", "dog"),

# object detection
proj3 <- create_object_detection_project(endp, "myobjdetproj")

regions <- list(
        tag=c("cat", "dog"),
        left=c(0.1, 0.5),
        top=c(0.25, 0.28),
        width=c(0.24, 0.21),
        height=c(0.7, 0.6)
        tag="cat", left=0.5, top=0.35, width=0.25, height=0.62
        tag="dog", left=0.07, top=0.12, width=0.79, height=0.5
add_images(proj3, c("catanddog.jpg", "cat.jpg", "dog.jpg"), regions=regions)

## End(Not run)

[Package AzureVision version 1.0.2 Index]