Closed philptt closed 3 years ago
All right, I found my error : the number of classes and classes texts did not match the number of bbox for a sample in the tfrecord file. I changed the code like this and it did the trick:
def create_tf_example(filepath, df_label):
encoded_image_data = open(filepath, "rb").read()
key = hashlib.sha256(encoded_image_data).hexdigest()
filename = os.path.basename(filepath)
image_name = filename.replace(".png", "")
height0 = df_label["height0"].loc[df_label["id"]==image_name].iloc[0]
width0 = df_label["width0"].loc[df_label["id"]==image_name].iloc[0]
image_format = b'png'
width = 256
height = 256
xmins = [x / width0 for x in df_label["xmins0"].loc[df_label["id"]==image_name].iloc[0]]
xmaxs = [x / width0 for x in df_label["xmaxs0"].loc[df_label["id"]==image_name].iloc[0]]
ymins = [x / height0 for x in df_label["ymins0"].loc[df_label["id"]==image_name].iloc[0]]
ymaxs = [x / height0 for x in df_label["ymaxs0"].loc[df_label["id"]==image_name].iloc[0]]
classes_text = ["opacity".encode("utf-8")]*len(xmins) # now it creates a list of strings with length equal to the number of bbox
classes = [0]*len(xmins) # now it creates a list of int with length equal to the number of bbox
tf_example = tf.train.Example(features=tf.train.Features(feature={
'image/height': tf.train.Feature(int64_list=tf.train.Int64List(value=[height])),
'image/width': tf.train.Feature(int64_list=tf.train.Int64List(value=[width])),
"image/filename": tf.train.Feature(bytes_list=tf.train.BytesList(value=[filename.encode("utf-8")])),
"image/source_id": tf.train.Feature(bytes_list=tf.train.BytesList(value=['0'.encode("utf-8")])), # Pb with image names solved with this hack
"image/key/sha256": tf.train.Feature(bytes_list=tf.train.BytesList(value=[key.encode("utf-8")])),
"image/encoded": tf.train.Feature(bytes_list=tf.train.BytesList(value=[encoded_image_data])),
"image/format": tf.train.Feature(bytes_list=tf.train.BytesList(value=["png".encode("utf-8")])),
"image/object/bbox/xmin": tf.train.Feature(float_list=tf.train.FloatList(value=xmins)),
"image/object/bbox/xmax": tf.train.Feature(float_list=tf.train.FloatList(value=xmaxs)),
"image/object/bbox/ymin": tf.train.Feature(float_list=tf.train.FloatList(value=ymins)),
"image/object/bbox/ymax": tf.train.Feature(float_list=tf.train.FloatList(value=ymaxs)),
"image/object/class/text": tf.train.Feature(bytes_list=tf.train.BytesList(value=classes_text)),
"image/object/class/label": tf.train.Feature(int64_list=tf.train.Int64List(value=classes)),
}))
return tf_example
Hi.
I'm trying to fine tune EfficientDet on a custom dataset using Google Colab (free). I'm new to tf so I tried to reproduce/modify an existing notebook (sorry if this question is stupid, I checked other issues concerning Gather_Nd here and tried some stuff but nothing worked). When training i get the following error:
Cannot get where that comes from, eventhough I'm aware that it could come from the TFrecord files. Here's how I generate them:
Same code for val.tfrecord.
I downloaded the model with this:
Config is this:
And here's how I start the training:
Thanks in advance for your help !