Toybrick

标题: rknn 能转换宽高都不固定的模型吗 [打印本页]

作者: wen0554    时间: 2020-9-25 15:02
标题: rknn 能转换宽高都不固定的模型吗
如题,我用keras训练了一个inputs是Shape(None,None,3)的模型,我该怎么转成rknn模型。

作者: jefferyzhang    时间: 2020-9-25 15:20
不能,请把宽高固定后再转rknn。

作者: wen0554    时间: 2020-9-26 10:00
可是我的模型就是这样的啊,如果确信大小,效果就差的远了
def res_block(x,sz,filter_sz=3,in_conv_size=1):
        xi  = x
        for i in range(in_conv_size):
                xi  = Conv2D(sz, filter_sz, activation='linear', padding='same')(xi)
                xi  = BatchNormalization()(xi)
                xi         = Activation('relu')(xi)
        xi  = Conv2D(sz, filter_sz, activation='linear', padding='same')(xi)
        xi  = BatchNormalization()(xi)
        xi         = Add()([xi,x])
        xi         = Activation('relu')(xi)
        return xi

def conv_batch(_input,fsz,csz,activation='relu',padding='same',strides=(1,1)):
        output = Conv2D(fsz, csz, activation='linear', padding=padding, strides=strides)(_input)
        output = BatchNormalization()(output)
        output = Activation(activation)(output)
        return output

def end_block(x):
        xprobs    = Conv2D(2, 3, activation='softmax', padding='same')(x)
        xbbox     = Conv2D(6, 3, activation='linear' , padding='same')(x)
        return Concatenate(3)([xprobs,xbbox])


def create_model_eccv():
       
        input_layer = Input(shape=(None,None,3),name='input')

        x = conv_batch(input_layer, 16, 3)
        x = conv_batch(x, 16, 3)
        x = MaxPooling2D(pool_size=(2,2))(x)
        x = conv_batch(x, 32, 3)
        x = res_block(x, 32)
        x = MaxPooling2D(pool_size=(2,2))(x)
        x = conv_batch(x, 64, 3)
        x = res_block(x,64)
        x = res_block(x,64)
        x = MaxPooling2D(pool_size=(2,2))(x)
        x = conv_batch(x, 64, 3)
        x = res_block(x,64)
        x = res_block(x,64)
        x = MaxPooling2D(pool_size=(2,2))(x)
        x = conv_batch(x, 128, 3)
        x = res_block(x,128)
        x = res_block(x,128)
        x = res_block(x,128)
        x = res_block(x,128)

        x = end_block(x)

        return Model(inputs=input_layer,outputs=x)





欢迎光临 Toybrick (https://t.rock-chips.com/) Powered by Discuz! X3.3