You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2023/04/20 15:55:29 UTC

[beam] branch users/damccorm/example-simplify created (now afaf90139ac)

This is an automated email from the ASF dual-hosted git repository.

damccorm pushed a change to branch users/damccorm/example-simplify
in repository https://gitbox.apache.org/repos/asf/beam.git


      at afaf90139ac Clean up tensorflow example

This branch includes the following new commits:

     new afaf90139ac Clean up tensorflow example

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[beam] 01/01: Clean up tensorflow example

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

damccorm pushed a commit to branch users/damccorm/example-simplify
in repository https://gitbox.apache.org/repos/asf/beam.git

commit afaf90139ac37b6d589714c7cd0484221cbb5757
Author: Danny McCormick <da...@google.com>
AuthorDate: Thu Apr 20 11:55:14 2023 -0400

    Clean up tensorflow example
---
 .../examples/inference/tensorflow_imagenet_segmentation.py       | 9 ++-------
 .../apache_beam/ml/inference/tensorflow_tests_requirements.txt   | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/sdks/python/apache_beam/examples/inference/tensorflow_imagenet_segmentation.py b/sdks/python/apache_beam/examples/inference/tensorflow_imagenet_segmentation.py
index 52863152538..c43acf88fbc 100644
--- a/sdks/python/apache_beam/examples/inference/tensorflow_imagenet_segmentation.py
+++ b/sdks/python/apache_beam/examples/inference/tensorflow_imagenet_segmentation.py
@@ -37,18 +37,13 @@ class PostProcessor(beam.DoFn):
   """Process the PredictionResult to get the predicted label.
   Returns predicted label.
   """
-  def __init__(self):
-    super().__init__()
-    self._imagenet_labels = None
-    self._labels_path = None
-
   def setup(self):
-    self._labels_path = tf.keras.utils.get_file(
+    labels_path = tf.keras.utils.get_file(
         'ImageNetLabels.txt',
         'https://storage.googleapis.com/download.tensorflow.org/data/ImageNetLabels.txt'  # pylint: disable=line-too-long
     )
     self._imagenet_labels = numpy.array(
-        open(self._labels_path).read().splitlines())
+        open(labels_path).read().splitlines())
 
   def process(self, element: PredictionResult) -> Iterable[str]:
     predicted_class = numpy.argmax(element.inference, axis=-1)
diff --git a/sdks/python/apache_beam/ml/inference/tensorflow_tests_requirements.txt b/sdks/python/apache_beam/ml/inference/tensorflow_tests_requirements.txt
index 03dca6ca234..8195059a6c1 100644
--- a/sdks/python/apache_beam/ml/inference/tensorflow_tests_requirements.txt
+++ b/sdks/python/apache_beam/ml/inference/tensorflow_tests_requirements.txt
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 
-tensorflow>=2.12.0rc1
+tensorflow>=2.12.0
 tensorflow_hub>=0.10.0
 Pillow>=9.0.0