Context manager open(file) as f fixes (#7289)

* Flask context manager `open()` fix

* Additional read context manager fixes
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-04-05 12:54:25 +02:00
1 parent 2181ef371e
commit 5f97001ed4
5 files changed
+17 -6

No files matched your search

+2 -1
View File
@@ -378,7 +378,8 @@ class DetectMultiBackend(nn.Module):
return x.prune(tf.nest.map_structure(ge, inputs), tf.nest.map_structure(ge, outputs))
gd = tf.Graph().as_graph_def() # graph_def
gd.ParseFromString(open(w, 'rb').read())
with open(w, 'rb') as f:
gd.ParseFromString(f.read())
frozen_func = wrap_frozen_graph(gd, inputs="x:0", outputs="Identity:0")
elif tflite or edgetpu: # https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python
try: # https://coral.ai/docs/edgetpu/tflite-python/#update-existing-tf-lite-code-for-the-edge-tpu