Multiple input tensorflow

I have model have structure like this:

           x1                               x2
        backbone                         backbone
             --------- concatenation --------
                            |
                   Fully Conected Layer
                            |
                          output

And I config data preparation like this:

class Data:
    data = []
    init = False
    datagen = ImageDataGenerator(rescale=1./255.)
    #initize
    def __init__(self, path, img_size = (640, 640)):
        all_file = os.listdir(path) #take all couple files
        #load couple images
        data1 = []
        data2 = []
        label = []
        for i in all_file:
            #take couple path
            if platform.system() == 'Darwin' and i.startswith('.'):
                continue
            temp_path = os.listdir(path + '/' + i)
            temp_path.pop(temp_path.index('label.txt'))
            f = open(path +'/' + i + '/label.txt', "r")
            label.append(int(f.read()))
            data1.append(cv2.resize(cv2.imread(path +'/' + i + '/' + temp_path[0]),img_size))
            data2.append(cv2.resize(cv2.imread(path +'/' + i + '/' + temp_path[1]),img_size))
            
        self.data = np.array([data1, data2])
        self.label = np.array(label)
        self.init = True

    def load_data_generator(self, b_size):
        if not self.init :
            raise Exception('Data need to be initialized first')
        # print(np.shape(self.data))
        # generator = self.datagen.flow(x = part_data,y = part_label, batch_size=8)
        
        genX1 = self.datagen.flow(x = self.data[0],
                                  y = self.label,
                                batch_size = b_size,
                                shuffle=False, 
                                seed=7)
    
        genX2 = self.datagen.flow(x = self.data[1],
                                  y = self.label,
                                batch_size = b_size,
                                shuffle=False, 
                                seed=7)
        while True:
            X1i = genX1.next()
            X2i = genX2.next()
            yield (X1i[0], X2i[0]), X2i[1]

However, I have a lot of error when I pass it into model.fit(). I need sample data preparation for my model:

resnet_1 = ResNet101(input_shape = (640, 640, 3), 
                                include_top = False, 
                                weights = None)
resnet_2 = ResNet101(input_shape = (640, 640, 3), 
                                include_top = False, 
                                weights = None)
x = resnet_1.layers[-2].output
y = resnet_2.layers[-2].output
#fix duplicate name
for layer in resnet_1.layers :
    layer._name = layer.name + str('_1')
for layer in resnet_2.layers :
    layer._name = layer.name + str('_2')
# combine the output of the two branches
combined = concatenate([x, y])
# apply a FC layer and then a regression prediction on the
# combined outputs
z = Dense(4096, activation="relu")(combined)
z = Dense(1, activation="sigmoid")(z)
# our model will accept the inputs of the two branches and
# then output a single value
model = Model(inputs=[resnet_1.input, resnet_2.input], outputs=z)
model.compile(loss=tf.keras.losses.BinaryCrossentropy(), optimizer='adam')

thank for read my problem

@Thien_Tan,

Welcome to the Tensorflow Forum,

I have a lot of error when I pass it into model.fit().

Could you please share more details of error stack trace?

Thank you!