apache_beam.ml.gcp.videointelligenceml module¶
A connector for sending API requests to the GCP Video Intelligence API.
- class apache_beam.ml.gcp.videointelligenceml.AnnotateVideo(features, location_id=None, metadata=None, timeout=120, context_side_input=None)[source]¶
Bases:
PTransform
A
PTransform
for annotating video using the GCP Video Intelligence API ref: https://cloud.google.com/video-intelligence/docsSends each element to the GCP Video Intelligence API. Element is a Union[str, bytes] of either an URI (e.g. a GCS URI) or bytes base64-encoded video data. Accepts an AsDict side input that maps each video to a video context.
- Parameters:
features – (List[
videointelligence_v1.Feature
]) Required. The Video Intelligence API features to detectlocation_id – (str) Optional. Cloud region where annotation should take place. If no region is specified, a region will be determined based on video file location.
metadata – (Sequence[Tuple[str, str]]) Optional. Additional metadata that is provided to the method.
timeout – (int) Optional. The time in seconds to wait for the response from the Video Intelligence API
context_side_input –
(beam.pvalue.AsDict) Optional. An
AsDict
of a PCollection to be passed to the _VideoAnnotateFn as the video context mapping containing additional video context and/or feature-specific parameters. Example usage:video_contexts = [('gs://cloud-samples-data/video/cat.mp4', Union[dict, ``videointelligence_v1.VideoContext``]), ('gs://some-other-video/sample.mp4', Union[dict, ``videointelligence_v1.VideoContext``]),] context_side_input = ( p | "Video contexts" >> beam.Create(video_contexts) ) videointelligenceml.AnnotateVideo(features, context_side_input=beam.pvalue.AsDict(context_side_input)))
- class apache_beam.ml.gcp.videointelligenceml.AnnotateVideoWithContext(features, location_id=None, metadata=None, timeout=120)[source]¶
Bases:
AnnotateVideo
A
PTransform
for annotating video using the GCP Video Intelligence API ref: https://cloud.google.com/video-intelligence/docsSends each element to the GCP Video Intelligence API. Element is a tuple of
(Union[str, bytes], Optional[videointelligence.VideoContext])
where the former is either an URI (e.g. a GCS URI) or bytes base64-encoded video data
- Parameters:
features – (List[
videointelligence_v1.Feature
]) Required. the Video Intelligence API features to detectlocation_id – (str) Optional. Cloud region where annotation should take place. If no region is specified, a region will be determined based on video file location.
metadata – (Sequence[Tuple[str, str]]) Optional. Additional metadata that is provided to the method.
timeout – (int) Optional. The time in seconds to wait for the response from the Video Intelligence API