You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/04/03 10:51:35 UTC

[GitHub] [beam] mwalenia commented on a change in pull request #11261: [BEAM-9147] Add a VideoIntelligence transform to Java SDK

mwalenia commented on a change in pull request #11261: [BEAM-9147] Add a VideoIntelligence transform to Java SDK
URL: https://github.com/apache/beam/pull/11261#discussion_r402921841
 
 

 ##########
 File path: sdks/java/extensions/ml/src/test/java/org/apache/beam/sdk/extensions/ml/VideoIntelligenceIT.java
 ##########
 @@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.extensions.ml;
+
+import static org.apache.beam.sdk.extensions.ml.VideoIntelligence.annotateFromURI;
+import static org.junit.Assert.assertEquals;
+
+import com.google.cloud.videointelligence.v1.Feature;
+import com.google.cloud.videointelligence.v1.VideoAnnotationResults;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.transforms.Create;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.transforms.SerializableFunction;
+import org.apache.beam.sdk.values.PCollection;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class VideoIntelligenceIT {
+  @Rule public TestPipeline testPipeline = TestPipeline.create();
+  private static final String VIDEO_URI =
+      "gs://apache-beam-samples/advanced_analytics/video/gbikes_dinosaur.mp4";
+  private List<Feature> featureList = Collections.singletonList(Feature.LABEL_DETECTION);
+
+  @Test
+  public void annotateVideoFromURINoContext() {
+    PCollection<List<VideoAnnotationResults>> annotationResults =
+        testPipeline
+            .apply(Create.of(VIDEO_URI))
+            .apply("Annotate video", ParDo.of(annotateFromURI(featureList, null)));
+    PAssert.that(annotationResults).satisfies(new VerifyVideoAnnotationResult());
+    testPipeline.run().waitUntilFinish();
+  }
+
+  private static class VerifyVideoAnnotationResult
+      implements SerializableFunction<Iterable<List<VideoAnnotationResults>>, Void> {
+
+    @Override
+    public Void apply(Iterable<List<VideoAnnotationResults>> input) {
+      List<Boolean> labelEvaluations = new ArrayList<>();
+      input.forEach(
 
 Review comment:
   Ok, done. What do you think?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services