I'm trying to do an object detection model on tensorflow with keras but I've been having so difficulty. I automated the task of finding the bounding boxes of my training images(training dataset is of a game) and dumped then all on a .csv file containing all the data pertaining to it: frame in which object appeared, coordinates of the bounding box, and class of the object. Each bounding box has a different row on the dataset even if multiple boxes appear on the same frame.
I'm trying to import my dataset into Tensorflow using this function:
def Data_Loader(annotation_file):
data=pd.read_csv(annotation_file)
data_groups=data.groupby('filename')
Dataset={'images':[], 'bounding_boxes':[]}
ngroups=data_groups.ngroups
for image_name, group in data_groups:
BBoxes={'classes': [], 'boxes':[]}
for _, row in group.iterrows():
BBoxes['boxes'].append(Get_BBOX(row))
BBoxes['classes'].append(class_ids.index(row['class']))
Dataset['bounding_boxes'].append(tf.data.Dataset.from_tensor_slices(BBoxes))
image=load_img(image_name,(224, 224))
Dataset['images'].append(tf.constant(image))
Dataset=tf.data.Dataset.from_tensor_slices(Dataset)
return(Dataset)
Where the following is how the bounding boxes are loaded:
def Get_BBOX(row):
xmin=int(row['xmin'])
ymin=int(row['ymin'])
xmax=int(row['xmax'])
ymax=int(row['ymax'])
bbox=np.array([xmin, ymin, xmax, ymax])
return bbox
And the image is loaded like this:
def load_img(filename, target_size):
img = tf.keras.utils.load_img(filename, target_size=target_size)
img = tf.keras.utils.img_to_array(img)
return (img)
I'm using this tutorial from Keras to guide myself
But whenever I reach the part of the tutorial for applying the map on the data, I get the following error message:
'_VariantDataset' object is not subscriptable
Anyone knows what I could be doing wrong and how to fix it?
I tried multiple times to make several conversions of types, changing from dictionaries containing list to lists of dictionaries and all other kinds of things. None of which yielded any results.