TFLITE model maker DataLoader.from_csv returns a None type

i am trying to load my datasets using a csv file using the DataLoader.from_csv('path to csv', images_dir = 'path to image directory) however when i go on to start training training the model i get an error AttributeError: 'NoneType' object has no attribute 'label_map'. it seems like whatever from returned from Dataloader.from_csv` was a None type

Hi @Ebyau_Bryan ! Can you show the code you are using to load the data. The function returns None only if it doesn’t find correct train, training,test data in the CSV.

This is my code for loading data from csv

from tflite_model_maker.object_detector import DataLoader

train_dir = '/content/drive/MyDrive/Training_demo/images/my_dataset/train'

train_data, validation_data, test_data = DataLoader.from_csv('/content/drive/MyDrive/Training_demo/annotations/train_dataset.csv', images_dir = train_dir)

@Ebyau_Bryan there should be no error if train_dir and train_dataset.csv exist. could you try loading the csv to pandas dataframe.

import pandas as pd
mycsv = pd.read_csv ('path')
mycsv.head()

and check if csv has loaded correctly

the csv file loads successfully,

it would be nice if I could see your collab file. Sorry, I should have asked about this earlier it would have been easier and faster for you.

alright this is link to my colab notebook
Colab notebook

@Ebyau_Bryan It works just fine for me on my dummy dataset… I don’t have your csv file or data but it seems like it is not in the format DataLoader is expecting pls look into Formatting a training data CSV | AutoML Vision Object Detection (google.com)

Alright . Are there scripts to format data into the required format for DataLoader otherthan using Google cloud AutoML Object Detection

Hi.

I had the same error and managed to identify that it was due to several factors:

  1. The file generated by the tagging tool did not have the required format, which is why I had to convert the file to the format specified in https://cloud.google.com/vision/automl/object-detection/docs/csv- format? hl = cs. To do this, use (provisionally) a spreadsheet (TensorFlow Lite - Data Preparation Template - Google Sheets).
  2. The value UNASSIGNED cannot be used. Each row must be specified as TRAINING, VALIDATION, or TEST.

Converting with a spreadsheet creates other minor issues that I fixed with a plain text editor. In the next few days I will create a Python script to convert to the indicated format.

Just wanted to say that I had the same issue and also fixed it by manually allocating my labels to TRAIN, VALIDATION or TEST, rather than relying on UNASSIGNED to do it for me.

Not sure if I’m misunderstanding the documentation—perhaps TFLite’s CSV loader is linking to the AutoML documentation because it uses the same spec but just doesn’t support the UNASSIGNED feature? The docs do say. ‘assigned to one of the above three sets by AutoML Vision Object Detection’ (emphasis mine). If this is indeed the case, perhaps the link from TFLite should note this qualification.

1 Like

Is this CSV format any type of standard or has any name that could be referred to?
Also the import function over at AutoML console did not really offer much help.

This is the format specified for TFLite specified at Formatting a training data CSV  |  AutoML Vision Object Detection  |  Google Cloud.
As I am not using AutoML, I had to modify the file manually.