I am trying to build a custom object detection model in jupyter notebook using tflite model maker but I have some problems.
I am getting images with pascal_voc (not csv) so I splited the train data/test data into different files
os.mkdir('C:/Users/user/Desktop/GradProject5/train_test_split/train')
os.mkdir('C:/Users/user/Desktop/GradProject5/train_test_split/test')
image_paths = os.listdir('C:/Users/user/anaconda3/envs/DarkflowTest/data/dataset')
random.shuffle(image_paths)
for i, image_path in enumerate(image_paths):
if i < int(len(image_paths) * 0.8):
shutil.copy(f'C:/Users/user/anaconda3/envs/DarkflowTest/data/dataset/{image_path}', 'C:/Users/user/Desktop/GradProject5/train_test_split/train')
shutil.copy(f'C:/Users/user/anaconda3/envs/DarkflowTest/data/annotations/{image_path.replace("jpg", "xml")}', 'C:/Users/user/Desktop/GradProject5/train_test_split/train')
else:
shutil.copy(f'C:/Users/user/anaconda3/envs/DarkflowTest/data/dataset/{image_path}', 'C:/Users/user/Desktop/GradProject5/train_test_split/test')
shutil.copy(f'C:/Users/user/anaconda3/envs/DarkflowTest/data/annotations/{image_path.replace("jpg", "xml")}', 'C:/Users/user/Desktop/GradProject5/train_test_split/test')
test_image_dir='C:/Users/user/Desktop/GradProject/\train_test_split/test/'
#annotations_dir = 'C:/Users/user/anaconda3/envs/DarkflowTest/data/annotations/'
train_data=object_detector.DataLoader.from_pascal_voc(train_image_dir+'image/',train_image_dir+'xml/',label_map={1:"pill",2:"text"})
test_datal=object_detector.DataLoader.from_pascal_voc(test_image_dir+'image/',test_image_dir+'xml/',label_map={1:"pill",2:"text"})
Then loaded train data and test data with DataLoader
model = object_detector.create(train_data, model_spec=spec, batch_size=2, train_whole_model=True)
Then I tried to create a model but I am getting this error.
[[1]: https://i.stack.imgur.com/ZBQtk.png][1]
ValueError Traceback (most recent call last) in ----> 1 model = object_detector.create(train_data, model_spec=spec, batch_size=2, train_whole_model=True)
~\anaconda3\lib\site-packages\tensorflow_examples\lite\model_maker\core\task\object_detector.py in create(cls, train_data, model_spec, validation_data, epochs, batch_size, train_whole_model, do_train) 285 if do_train: 286 tf.compat.v1.logging.info('Retraining the models...') --> 287 object_detector.train(train_data, validation_data, epochs, batch_size) 288 else: 289 object_detector.create_model()
~\anaconda3\lib\site-packages\tensorflow_examples\lite\model_maker\core\task\object_detector.py in train(self, train_data, validation_data, epochs, batch_size) 137 # TODO(b/171449557): Upstream this to the parent class. 138 if len(train_data) < batch_size: --> 139 raise ValueError('The size of the train_data (%d) couldn't be smaller ' 140 'than batch_size (%d). To solve this problem, set ' 141 'the batch_size smaller or increase the size of the '
ValueError: The size of the train_data (0) couldn't be smaller than batch_size (2). To solve this problem, set the batch_size smaller or increase the size of the train_data.
Am I getting error because
train_data=object_detector.DataLoader.from_pascal_voc(train_image_dir+'image/',train_image_dir+'xml/',label_map={1:"pill",2:"text"})
it failed to load train data..?
I think I did everything right and still struggling with this error..
Please help me if you know the solution to this problem!