MyNixOS website logo
Description

Interface to Azure Computer Vision Services.

An interface to 'Azure Computer Vision' <https://docs.microsoft.com/azure/cognitive-services/Computer-vision/Home> and 'Azure Custom Vision' <https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/home>, building on the low-level functionality provided by the 'AzureCognitive' package. These services allow users to leverage the cloud to carry out visual recognition tasks using advanced image processing models, without needing powerful hardware of their own. Part of the 'AzureR' family of packages.

AzureVision

CRAN Downloads R-CMD-check

An R frontend to Azure Computer Vision and Azure Custom Vision, building on the low-level functionality provided by the AzureCognitive package. These services let you leverage the cloud to carry out visual recognition tasks using advanced image processing models, without needing powerful hardware of your own.

The primary repo for this package is at https://github.com/Azure/AzureVision; please submit issues and PRs there. It is also mirrored at the Cloudyr org at https://github.com/cloudyr/AzureVision. You can install the development version of the package with devtools::install_github("Azure/AzureVision").

Computer Vision

To communicate with the Computer Vision service, call the computervision_endpoint function with the service URL and key. Rather than a key, you can also supply an OAuth token obtained with the AzureAuth package.

library(AzureVision)

vis <- computervision_endpoint(
    url="https://accountname.cognitiveservices.azure.com/",
    key="account_key"
)

# images can be specified as a filename, Internet URL, or raw vector
bill_url <- "https://news.microsoft.com/uploads/2014/09/billg1_print.jpg"
analyze(vis, bill_url)
# $categories
#      name    score
# 1 people_ 0.953125

describe(vis, bill_url)
# $tags
#  [1] "person"   "man"      "suit"     "clothing" "necktie"  "wearing"  "glasses"  "looking"  "holding"  "standing" "older"   
# [12] "posing"   "business" "old"      "dressed"  "front"    "sitting"  "black"    "hat"      "white"    "sign"     "phone"   

# $captions
#                                text confidence
# 1 Bill Gates wearing a suit and tie  0.9954072

Custom Vision

Custom Vision defines two different types of endpoint: a training endpoint, and a prediction endpoint. To communicate with these, call the customvision_training_endpoint and customvision_prediction_endpoint functions with the service URL and key.

# training a model
cusvis <- customvision_training_endpoint(
    url="https://location.api.cognitive.microsoft.com/",
    key="training_key"
)

# different projects can exist on the one endpoint
list_projects(cusvis)

# create a classification project (one tag/label per image)
proj <- create_classification_project(cusvis, "myproject")

img1 <- dir("path/to/images/tag1", full.names=TRUE)
img2 <- dir("path/to/images/tag2", full.names=TRUE)
add_images(proj, img1, tags="tag1")
add_images(proj, img2, tags="tag2")

# train the model
mod <- train_model(proj)

# publish to the prediction resource (use AzureRMR framework to get resource ID)
pred_res <- AzureRMR::get_azure_login("mytenant")$
    get_subscription("sub_id")$
    get_resource_group("rgname")$
    get_cognitive_service("cusvis_prediction")

publish_model(mod, "mymodel", pred_res)

# get predictions from the prediction endpoint
cusvis_pred <- customvision_prediction_endpoint(
    url="https://location.api.cognitive.microsoft.com/",
    key="prediction_key"
)

# must supply project ID to access the published service
project_id <- proj$project$id
cusvis_service <- classification_service(cusvis_pred, project_id, "mymodel")

predict(cusvis_service, "testimage.jpg")

Resource Manager interface

You can create Computer Vision and Custom Vision resources using the AzureRMR framework.

For Computer Vision, the available service tiers are F0 (free, limited to 20 API calls per minute and 5k calls per month) and S1 (up to 10 calls per second). For Custom Vision, the tiers are F0 (free, limited to 2 projects for training and 10k transactions/month for prediction) and S0. Note that Custom Vision requires at least two resources: one for training, and the other for prediction.

rg <- AzureRMR::get_azure_login("yourtenant")$
    get_subscription("sub_id")$
    get_resource_group("rgname")

# Computer Vision
rg$create_cognitive_service("myvis", service_type="ComputerVision", service_tier="S1")

# Custom Vision (training and prediction)
rg$create_cognitive_service("mycustvis", service_type="CustomVision", service_tier="S0")
rg$create_cognitive_service("mycustvispred", service_type="CustomVision.Prediction", service_tier="S0")

Metadata

Version

1.0.2

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows