def create_tf_example(example):
img_fpath = os.path.join('object_detection/my_data', example[0])
img = Image.open(img_fpath)
height = img.size[1]
width = img.size[0]
filename = str.encode(example[0])
with open(img_fpath, mode='rb') as f:
encoded_image_data = f.read()
image_format = b'jpeg'
writer = tf.python_io.TFRecordWriter('object_detection/my_data/train_data.record')
.......
for file_name, row in annot.iterrows():
tf_example = create_tf_example(row)
writer.write(example.SerializeToString())
writer.close
FileNotFoundError Traceback (most recent call last)
<ipython-input-10-c1ce7673f3b3> in <module>()
2
3 for file_name, row in annot.iterrows():
----> 4 tf_example = create_tf_example(row)
5 writer.write(example.SerializeToString())
6
<ipython-input-9-6b649f10f72c> in create_tf_example(example)
2
3 img_fpath = os.path.join('object_detection/my_data', example[0])
----> 4 img = Image.open(img_fpath)
5 height = img.size[1]
6 width = img.size[0]
/usr/local/lib/python3.6/dist-packages/PIL/Image.py in open(fp, mode)
2528
2529 if filename:
-> 2530 fp = builtins.open(filename, "rb")
2531 exclusive_fp = True
2532
FileNotFoundError: [Errno 2] No such file or directory: 'object_detection/my_data/2325670467.jpg'()