(-215:断言失败)训练数据集时函数'cv :: cvtColor'中的!_src.empty()错误

时间:2020-04-17 21:22:31

标签: python opencv machine-learning training-data

我一直在尝试训练数据集。 directory 这是我将训练图像放入images并将json文件放入annotations的文件。 另外,Train.pyenter image description here中 然后我执行了这两个命令。

cd C:\Users\mustafa\Desktop\EfficientDet-master

python train.py --snapshot imagenet --phi 0 --gpu 0 --random-transform --compute-val-loss --freeze-backbone --batch-size 4 --steps 100 coco C:/Users/mustafa/Downloads/deneme.v1-1.coco/datasets/coco

此后,我已经看到此错误。

Traceback (most recent call last):
  File "train.py", line 381, in <module>
    main()
  File "train.py", line 376, in main
    validation_data=validation_generator
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\util\depr
ecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\keras\eng
ine\training.py", line 1577, in fit_generator
    initial_epoch=initial_epoch)
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\keras\eng
ine\training.py", line 71, in _method_wrapper
    return method(self, *args, **kwargs)
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\keras\eng
ine\training.py", line 886, in fit
    steps_per_execution=self._steps_per_execution)
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\keras\eng
ine\data_adapter.py", line 1138, in __init__
    model=model)
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\keras\eng
ine\data_adapter.py", line 923, in __init__
    **kwargs)
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\keras\eng
ine\data_adapter.py", line 787, in __init__
    peek, x = self._peek_and_restore(x)
  File "C:\Users\mustafa\anaconda3\lib\site-packages\tensorflow\python\keras\eng
ine\data_adapter.py", line 927, in _peek_and_restore
    return x[0], x
  File "C:\Users\mustafa\Desktop\EfficientDet-master\generators\common.py", line
 424, in __getitem__
    inputs, targets = self.compute_inputs_targets(group)
  File "C:\Users\mustafa\Desktop\EfficientDet-master\generators\common.py", line
 373, in compute_inputs_targets
    image_group = self.load_image_group(group)
  File "C:\Users\mustafa\Desktop\EfficientDet-master\generators\common.py", line
 225, in load_image_group
    return [self.load_image(image_index) for image_index in group]
  File "C:\Users\mustafa\Desktop\EfficientDet-master\generators\common.py", line
 225, in <listcomp>
    return [self.load_image(image_index) for image_index in group]
  File "C:\Users\mustafa\Desktop\EfficientDet-master\generators\coco.py", line 1
32, in load_image
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\co
lor.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtCo
lor'
load_image中的

coco.py函数

def load_image(self, image_index):
        """
        Load an image at the image_index.
        """
        # {'license': 2, 'file_name': '000000259765.jpg', 'coco_url': 'http://images.cocodataset.org/test2017/000000259765.jpg', 'height': 480, 'width': 640, 'date_captured': '2013-11-21 04:02:31', 'id': 259765}
        image_info = self.coco.loadImgs(self.image_ids[image_index])[0]
        path = os.path.join(self.data_dir, 'images', self.set_name, image_info['file_name'])
        print(path)
        image = cv2.imread(path)
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        return image

0 个答案:

没有答案