admin管理员组

文章数量:1202373

I am trying to make a deepfake detection model which will work on both audio and video(Using mobilenetv2), thus, i am trying to build a model which will work on both

def build_model(input_shape=(224, 224, 3), num_classes=10):
    frames_input = Input(shape=input_shape, name="frames_input")
    spectrogram_input = Input(shape=input_shape, name="spectrogram_input")

    x1 = MobileNetV2(weights="imagenet", include_top=False, input_tensor=frames_input)
    for i, layer in enumerate(x1.layers):
        layer._name = f"mobilenet_frames_{i}"

    x1 = Flatten()(x1.output)

    x2 = MobileNetV2(weights="imagenet", include_top=False, input_tensor=spectrogram_input)
    for i, layer in enumerate(x2.layers):
        layer._name = f"mobilenet_spectrogram_{i}"

    x2 = Flatten()(x2.output)

    merged = Concatenate()([x1, x2])

    x = Dense(1024, activation="relu", name="dense_1")(merged)
    x = Dense(512, activation="relu", name="dense_2")(x)
    output = Dense(num_classes, activation="softmax", name="output")(x)

    model = Model(inputs=[frames_input, spectrogram_input], outputs=output, name="deepfake_detection_model")

    return model

the error is: ValueError: The name "Conv1" is used 2 times in the model. All operation names should be unique.

本文标签: