CNN with RGB input and BW binary output

I begin deep training and I work with Keras built on top of Tensorflow. I am trying to use RGB resolution (540 x 360) to predict bounding rectangles.

My shortcuts are a binary (black / white) 2-dimensional np-array of sizes (540, 360), where all the pixels are 0, except for the edges of the boxes, which are 1. Like this:

   [[0 0 0 0 0 0 ... 0]
    [0 1 1 1 1 0 ... 0]
    [0 1 0 0 1 0 ... 0]
    [0 1 0 0 1 0 ... 0]
    [0 1 1 1 1 0 ... 0]
    [0 0 0 0 0 0 ... 0]]

Each image may have more than one bounding box. A typical image might look like this:FRCBox

So, my input has a size (None, 540, 360, 3), the output has dimensions (None, 540, 360), but if I add an internal array, I can change the form to(None, 540, 360, 1)

How can I define a CNN model so that my model meets these criteria? How can I create CNN with these inputs and outputs?

+4
3

. , CNN -.

CNR /, . 4 , , , . R-CNN, SSD YOLO, keras. , 4 .

, -, , , . SegNet, U-Net Tiramisu, keras. U-Net . , 0s 1s. , , , .

, , . . , , , . , , , .

+1

, . .

def model_360x540(input_shape=(360, 540, 3),num_classes=1):

    inputs = Input(shape=input_shape)
    # 360x540x3

    downblock0 = Conv2D(32, (3, 3), padding='same')(inputs)
    # 360x540x32
    downblock0 = BatchNormalization()(block0)
    downblock0 = Activation('relu')(block0)
    downblock0_pool = MaxPooling2D((2, 2), strides=(2, 2))(block0)
    # 180x270x32

    centerblock0 = Conv2D(1024, (3, 3), padding='same')(downblock0_pool)
    #180x270x1024
    centerblock0 = BatchNormalization()(center)
    centerblock0 = Activation('relu')(center)


    upblock0 = UpSampling2D((2, 2))(centerblock0)
    # 180x270x32
    upblock0 = concatenate([downblock0 , upblock0], axis=3)
    upblock0 = Activation('relu')(upblock0)
    upblock0 = Conv2D(32, (3, 3), padding='same')(upblock0)
    # 360x540x32
    upblock0 = BatchNormalization()(upblock0)
    upblock0 = Activation('relu')(upblock0)


    classify = Conv2D(num_classes, (1, 1), activation='sigmoid')(upblock0)
    #360x540x1

    model = Model(inputs=inputs, outputs=classify)

    model.compile(optimizer=RMSprop(lr=0.001), loss=bce_dice_loss, metrics=[dice_coeff])

    return model

downblock , (MaxPooling2D).

.

upblock , (UpSampling2D).

, , (360,540,3) (360,540,1)

, .

, .

, !

+1

keras, , . .

  • : , , , , , , ( ). (Box, Edges of box background). : " ". Image Labeling Scheme

  • ( RESNET-51) , fc1000 de-convolution/up-sampling, . paddding , deconvolution, .

  • () .

  • Test your dataset and create bounding fields using detected blocks.

+1
source

Source: https://habr.com/ru/post/1692185/


All Articles