tf.io.gfile.Open() 的 TensorFlow2 替代方案?

TensorFlow2 alternative to tf.io.gfile.Open()?

我正尝试通过 Machine Learning with Apache Beam and TensorFlow 但使用 TF2。 (Python) 源全部是 TF1,我正在使用 TF1 函数玩 whackamole。这个让我被屏蔽了:with tf.io.gfile.Open(sdf_file, 'w') TF2 tf.io.gfile 没有 Open

在示例代码中,所有这些都是读取从 PubChem 下载的文件。 PubChem 文件可以不是 SDF,所以这不会破坏交易,但我想尽可能接近 Apache Beam 和 TensorFlow 示例中的源代码。

这是我在官方文档中看到的TF2模型花园示例: with tf.gfile.GFile(os.path.join(path, '{}'.format(group.filename)), 'rb') as fid: encoded_jpg = fid.read()。请参考此 link [https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html]