В annot есть файлы которых нет в test_jpg, и поэтому выходит такая ошибка дайте подсказку неучу токо дельную а не типа иди учи питон или вам на биржу я помощи прошу а не весь код написать
def create_tf_example(example):
img_fpath = os.path.join('object_detection/my_data/test_jpg', example[0])
img = Image.open(img_fpath)
height = img.size[1]
width = img.size[0]_
with open(img_fpath, mode='rb') as f:
encoded_image_data = f.read()
image_format = b'jpeg'
# List of normalized left x coordinates in bounding box (1 per box)
xmins = [example.xmin / float(width)]
#xmins = [example.xmin / float(width)]
# List of normalized right x coordinates in bounding box # (1 per box)
# xmaxs = [example.xmax/ float(width), example.xmax/ float(width), example.xmax/ float(width)]
#width= [example.width / float(width)]
# List of normalized top y coordinates in bounding box (1 per box)
ymins = [example.ymin / float(height)]
#ymins = [example.ymin / float(height)]
# List of normalized bottom y coordinates in bounding box # (1 per box)
#ymaxs = [example.ymax/ float(height), example.ymax/ float(height), example.ymax / float(height)]
#height= [example.height / float(height)]
# List of string class name of bounding box (1 per box)
classes_text = [b'google', b'apple', b'adidas', b'HP', b'stellaartois', b'paulaner', b'guiness', b'singha', b'cocacola', b'dhl', b'texaco', b'fosters', b'fedex', b'aldi', b'chimay', b'shell', b'becks', b'tsingtao', b'ford', b'carlsberg',
b'bmw', b'pepsi', b'esso', b'heineken', b'erdinger', b'corona', b'milka', b'ferrari', b'nvidia', b'rittersport', b'ups', b'starbucks']
# List of integer class id of bounding box (1 per box)
classes = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]
tf_example = tf.test.Example(features=tf.train.Features(feature={
'image/height': dataset_util.int64_feature(height),
'image/width': dataset_util.int64_feature(width),
'image/filename': dataset_util.bytes_feature(filename),
'image/source_id': dataset_util.bytes_feature(filename),
'image/encoded': dataset_util.bytes_feature(encoded_image_data),
'image/format': dataset_util.bytes_feature(image_format),
'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
'image/object/class/label': dataset_util.int64_list_feature(classes),
}))
return tf_example
writer = tf.python_io.TFRecordWriter('object_detection/my_data/test_data.record')
for file_name, row in annot.iterrows():
tf_example = create_tf_example(row)
writer.write(tf_example.SerializeToString())
writer.close()
FileNotFoundError Traceback (most recent call last)
in ()
2
3 for file_name, row in annot.iterrows():
----> 4 tf_example = create_tf_example(row)
5 writer.write(tf_example.SerializeToString())
6
1 frames
in create_tf_example(example)
2
3 img_fpath = os.path.join('object_detection/my_data/test_jpg', 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/test_jpg/2325670467.jpg'