Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带有多个标签的ImageDataGenerator_Python_Tensorflow_Keras - Fatal编程技术网

Python 带有多个标签的ImageDataGenerator

Python 带有多个标签的ImageDataGenerator,python,tensorflow,keras,Python,Tensorflow,Keras,我试图在tensorflow中实现分类和对象检测(图像中只有一个对象,因此输出由bbox的4个坐标组成)。我想使用ImageDataGenerator进行图像增强 我的部分代码: # partition the data into training and testing splits using 75% of # the data for training and the remaining 25% for validating and testing split_1 = train_test

我试图在tensorflow中实现分类和对象检测(图像中只有一个对象,因此输出由bbox的4个坐标组成)。我想使用ImageDataGenerator进行图像增强

我的部分代码:

# partition the data into training and testing splits using 75% of
# the data for training and the remaining 25% for validating and testing
split_1 = train_test_split(data, labels, bboxes, imagePaths,
                           test_size=0.25, random_state=42)

# unpack the first data split
(trainImages, valid_testImages) = split_1[:2]
(trainLabels, valid_testLabels) = split_1[2:4]
(trainBBoxes, valid_testBBoxes) = split_1[4:6]
(trainPaths, valid_testPaths) = split_1[6:]
                       
# partition the valid/test data into validation and testing splits using 0.8% of
# the data for validation and the remaining 20% for testing
split_2 = train_test_split(valid_testImages, valid_testLabels, valid_testBBoxes, 
                           valid_testPaths, test_size=0.2, random_state=42)

# unpack the second data split
(validImages, testImages) = split_2[:2]
(validLabels, testLabels) = split_2[2:4]
(validBBoxes, testBBoxes) = split_2[4:6]
(validPaths, testPaths) = split_2[6:]


# construct a dictionary for target training outputs
trainTargets = {
                'class_label': trainLabels,
                'bounding_box':trainBBoxes
                }

# construct a second dictionary, this one for our target testing
# outputs
validTargets = {
               'class_label':validLabels,
               'bounding_box':validBBoxes
               }

# for simplicity debugging ImageDataGenerator only rescales images
aug = ImageDataGenerator(rescale=1./255)

H = model.fit(x=aug.flow(trainImages, batch_size=BATCH_SIZE),
              y=trainTargets, 
              validation_data=(validImages, validTargets),
              batch_size=BATCH_SIZE,
              epochs=config.NUM_EPOCHS,
              callbacks=callbacks,
              verbose=1)

当我训练模型时,我有下一个错误:

Traceback (most recent call last):
  File "train.py", line 278, in <module>
    verbose=1)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py", line 1064, in fit
    steps_per_execution=self._steps_per_execution)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/data_adapter.py", line 1112, in __init__
    model=model)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/data_adapter.py", line 892, in __init__
    raise ValueError("`y` argument is not supported when using "
ValueError: `y` argument is not supported when using `keras.utils.Sequence` as input.
回溯(最近一次呼叫最后一次):
文件“train.py”,第278行,在
详细=1)
文件“/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py”,第1064行,适合
每执行一步=自。\每执行一步)
文件“/usr/local/lib/python3.7/dist packages/tensorflow/python/keras/engine/data_adapter.py”,第1112行,在u init中__
模型=模型)
文件“/usr/local/lib/python3.7/dist packages/tensorflow/python/keras/engine/data_adapter.py”,第892行,在u init中__
raise VALUERROR('y'参数在使用时不受支持)
ValueError:'y'参数在使用'keras.utils.Sequence'作为输入时不受支持。
对解决这个问题有什么建议吗