Class CloudVision

java.lang.Object
org.apache.beam.sdk.extensions.ml.CloudVision

public class CloudVision extends Object
Factory class for implementations of AnnotateImages.

Example usage:

 pipeline
  .apply(Create.of(IMAGE_URI))
  .apply(CloudVision.annotateImagesFromGcsUri(sideInputWithContext,
         features, 1, 1));
 
  • Constructor Details

    • CloudVision

      public CloudVision()
  • Method Details

    • annotateImagesFromGcsUri

      public static CloudVision.AnnotateImagesFromGcsUri annotateImagesFromGcsUri(PCollectionView<Map<String,com.google.cloud.vision.v1.ImageContext>> contextSideInput, List<com.google.cloud.vision.v1.Feature> features, long batchSize, int desiredRequestParallelism)
      Creates a PTransform that annotates images from their GCS addresses.
      Parameters:
      contextSideInput - optional side input with contexts for select images. The ImageContext objects provide additional metadata for the annotation API. This way users can
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      desiredRequestParallelism - desired number of concurrent batched requests.
      Returns:
      the PTransform.
    • annotateImagesFromGcsUri

      public static CloudVision.AnnotateImagesFromGcsUri annotateImagesFromGcsUri(PCollectionView<Map<String,com.google.cloud.vision.v1.ImageContext>> contextSideInput, List<com.google.cloud.vision.v1.Feature> features, long batchSize)
      Creates a PTransform that annotates images from their GCS addresses. Uses a default value 5 for desiredRequestParallelism.
      Parameters:
      contextSideInput - optional side input with contexts for select images. The ImageContext objects provide additional metadata for the annotation API. This way users can fine-tune analysis of selected images.
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      Returns:
      the PTransform.
    • annotateImagesFromBytes

      public static CloudVision.AnnotateImagesFromBytes annotateImagesFromBytes(PCollectionView<Map<ByteString,com.google.cloud.vision.v1.ImageContext>> contextSideInput, List<com.google.cloud.vision.v1.Feature> features, long batchSize, int desiredRequestParallelism)
      Creates a PTransform that annotates images from their contents encoded in ByteStrings.
      Parameters:
      contextSideInput - optional side input with contexts for select images. The ImageContext objects provide additional metadata for the annotation API. This way users can fine-tune analysis of selected images.
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      desiredRequestParallelism - desired number of concurrent batched requests.
      Returns:
      the PTransform.
    • annotateImagesFromBytes

      public static CloudVision.AnnotateImagesFromBytes annotateImagesFromBytes(PCollectionView<Map<ByteString,com.google.cloud.vision.v1.ImageContext>> contextSideInput, List<com.google.cloud.vision.v1.Feature> features, long batchSize)
      Creates a PTransform that annotates images from their contents encoded in ByteStrings. Uses a default value 5 for desiredRequestParallelism.
      Parameters:
      contextSideInput - optional side input with contexts for select images. The ImageContext objects provide additional metadata for the annotation API. This way users can fine-tune analysis of selected images.
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      Returns:
      the PTransform.
    • annotateImagesFromBytesWithContext

      public static CloudVision.AnnotateImagesFromBytesWithContext annotateImagesFromBytesWithContext(List<com.google.cloud.vision.v1.Feature> features, long batchSize, int desiredRequestParallelism)
      Creates a PTransform that annotates images from KVs of their GCS addresses in Strings and ImageContext for each image.
      Parameters:
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      desiredRequestParallelism - desired number of concurrent batched requests.
      Returns:
      the PTransform.
    • annotateImagesFromBytesWithContext

      public static CloudVision.AnnotateImagesFromBytesWithContext annotateImagesFromBytesWithContext(List<com.google.cloud.vision.v1.Feature> features, long batchSize)
      Creates a PTransform that annotates images from KVs of their GCS addresses in Strings and ImageContext for each image. Uses a default value 5 for desiredRequestParallelism.
      Parameters:
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      Returns:
      the PTransform.
    • annotateImagesFromGcsUriWithContext

      public static CloudVision.AnnotateImagesFromGcsUriWithContext annotateImagesFromGcsUriWithContext(List<com.google.cloud.vision.v1.Feature> features, long batchSize, int desiredRequestParallelism)
      Creates a PTransform that annotates images from KVs of their String-encoded contents and ImageContext for each image.
      Parameters:
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      desiredRequestParallelism - desired number of concurrent batched requests.
      Returns:
      the PTransform.
    • annotateImagesFromGcsUriWithContext

      public static CloudVision.AnnotateImagesFromGcsUriWithContext annotateImagesFromGcsUriWithContext(List<com.google.cloud.vision.v1.Feature> features, long batchSize)
      Creates a PTransform that annotates images from KVs of their String-encoded contents and ImageContext for each image. Uses a default value 5 for desiredRequestParallelism.
      Parameters:
      features - annotation features that should be passed to the API
      batchSize - request batch size to be sent to API. Max 16, at least 1.
      Returns:
      the PTransform.