Tensor's data type is not supported in function 'blobFromTensor" in python

I tried to train from keras for my own project. However, I encounter an error that Tensor's data type is not supported in function 'bloblFromTensor' from the use of cv2.readNetFromTensorflow or cv2.readNet.

I used K.set_learing_phase(0) befor I build model

my model build is

def build(width, height, depth, classes):

        model = K.models.Sequential()
        inputShape = (height, width, depth)
        print(" there is the inputShape for hidden layers : {}  ".format(inputShape))

        # todo if  u delete set_learning, the result return it that below
        # raise ValueError("Tensor name '{0}' is invalid.".format(node.input[0]))
        # dk.set_learning_phase(0)

        # first hidden layers
        model.add(K.layers.Dense(16, input_shape=inputShape))

        # first set of convv => relu => pool layers
        model.add(K.layers.Conv2D(32, (7, 7), padding="same", activation="relu"))

        # init dense layer for image resolution
        model.add(K.layers.Dense(64, activation="relu"))

        model.add(K.layers.Conv2D(64, (3, 3), padding="same", activation="relu"))

        model.add(K.layers.Conv2D(128, (3, 3), activation="relu", padding="same"))

        # (None, 7, 7, 50) -> model.output_shape
        a, b, c, d = model.output_shape
        print("model ouput_shape giving ", a, b, c, d)
        a = b * c * d
        print("a -> ", a)

        model.add(K.layers.Permute([1, 2, 3]))

        # first set of fc => relu layers
        model.add(K.layers.Dense(units=512, activation='relu'))

        # model.add(K.layers.Flatten())
        # sofmax classifier
        model.add(K.layers.Dense(units=classes, activation='softmax'))

        return model

So, I used fit_generation method for history of training then applied

# save file of model

    # freeze the graph to pb file and pbtxt
    # ! not showing to console because that so take a long time
    frozen_graph = freeze_session(sess, output_names=[out.op.name for out in model.outputs])

    # convert to keras file to pb files for using readNetTensorflow
        tf.io.write_graph(frozen_graph, learn_path, model_file , as_text=False)
        log_file.register(0,"graph file saving to pb is success ")
    except ValueError as er:
        console_log.d("ERROR -> NOT CONVERT TO PB FILE ",er)
        log_file.register(1, " ERROR that convert to pbfile : {} ".format(er))

    console_log.d("FROZEN GRAPH TO PB FILE ")

    # pb file convert to pbtxt file
    create_pbtxt(model_file , pbtxt_file, learn_path )

finally, I converted pb file to pbtxt file with some node deleted

def create_pbtxt(pb_path, pbtxt_path, path):

    # clear console

    console_log.d("CREATE_TXT FILE")
    console_log.d("there is the path file is this - --- > " , pb_path )

    # check path file from the news
    found_path_file = path + "/" + pb_path

    console_log.d("original path that saving here:",found_path_file)
    with tf.Session() as sess:
        with tf.gfile.GFile(found_path_file, 'rb')as f:
            # tf.io.compat
            graph_def = tf.GraphDef()
            # graph_def.ParseFromString(f.read())
               # text_format.Merge(f.read(), graph_def)
               tf.import_graph_def(graph_def, name='')
               console_log.d("pbtxt file is saving ")
            except text_format.ParseError:
                console_log.d("error from merge file for text_format")

            # inp_node = 'MobilenetV2/MobilenetV2/input'
            # oup_node = 'logits/semantic/BiasAdd'
            # gragh_def = optimize_for_inference_lib.optim─čize_for_inference()

            name_array =[ ]

            # print("graph_def_node is here: ", graph_def.node)
            # for i in reversed((range(len(graph_def.node) ))):

            for i in reversed(range(len(graph_def.node))):
                # if op == 'Switch' or op == 'Merge':
                #     inp = graph_deadnode[i].input[0]
                #     print("inp : {}".format(inp))

                # graph_def node for addConstNodes error that
                log_file.register(0, " file is node for reversed : {} ".format(graph_def.node[i].op))
                # cv2 test file return addConstNode error from Const node exist (maybe)
                if graph_def.node[i].op =='Const':
                    console_log.d("found const variables!!!")
                    # console clear
                    del graph_def.node[i]

            # if graph_def.op == 'Const':
            #     os.system("clear")
            #     console_log.d("node deleting Cons ")
            #     console_log.d("graph_def.node[i]: ".format(graph_def.node[i]) )
            #     del graph_def.node[i]

            # !  extends adding for any error that return cv2 test file
            for attr in ['T', 'data_format', 'Tshape', 'N', 'Tidx', 'Tdim','use_cudnn_on_gpu', 'Index', 'Tperm', 'is_training','Tpaddings']:
                if attr in graph_def.node[i].attr:
                    console_log.d(" THERE IS THE ATTR ")
                    del graph_def.node[i].attr[attr]

            op = graph_def.node[i].op
            print("op: {}".format(op))
            name = graph_def.node[i].name
            print("name : {} ".format(name))
            # todo , try to op and name from nodes to logs file
            # convert to np array for values save to logs file
            op2_array = np.array(op_array)
            name2_array = np.array(name_array)

            # send values for logs
            log_file.register(0," op : {} , name:{} ".format(op2_array, name2_array))

    # saving pbtxt file from pb file that convert
    tf.io.write_graph( graph_def, path, pbtxt_path, as_text=True)

This issue from testing.py. when debug cursor comes the cv2.readNetTensorflow or cv2.readNet, program returns " Tensor's data type is not supported in function 'blobFromTensor "

this is the testing.py

# check the pbtxt with or without processing
    if flags.text_file is None: 
        net = cv2.dnn.readNet(pb_file)
        txt_file = os.getcwd() + "/" + flags.text_file
        net = cv2.dnn.readNetFromTensorflow(pb_file,txt_file)

Why do I get the error? I have no idea. Please help me.