Open Mostafa-elgendy opened 4 years ago
Generally you need to un-barriered the anchor number check in train.py and adjust the feature layer number & corresponding y_true feeding mechanism in model.py and data.py. But that may not be easy since there're many related dependencies. Another approach is treating the model as a "fake" YOLOv3 model ("three Yolo layers" is just one of core design of YOLOv3) and build up your model struct under models dir, then register it to the train process. For anchors you can use you own definition or migrate the tiny yolo 6 anchors to 9 if needed.
I am using your code and I want to change the tiny-yolov3 by adding three Yolo layers instead of two. I want to ask how to change the other files to reflect that because anchor file will contain nine items instead of six, could you help me? note that i have changed this method to be like this def tiny_yolo3lite_body(inputs, num_anchors, num_classes): '''Create Tiny YOLO_v3 Lite model CNN body in keras.''' x11 = compose( Depthwise_Separable_Conv2D_BN_Leaky(16, (3,3)),#0 MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#1 Depthwise_Separable_Conv2D_BN_Leaky(32, (3,3)),#2 MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#3 Depthwise_Separable_Conv2D_BN_Leaky(64, (3,3)),#4 MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#5 Depthwise_Separable_Conv2D_BN_Leaky(128, (3,3)))(inputs)#6 x1 = compose( MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#7 Depthwise_Separable_Conv2D_BN_Leaky(256, (3,3)))(x11)#8 x2 = compose( MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#9 Depthwise_Separable_Conv2D_BN_Leaky(512, (3,3)),#10 MaxPooling2D(pool_size=(2,2), strides=(1,1), padding='same'),#11 Depthwise_Separable_Conv2D_BN_Leaky(1024, (3,3)),#12 DarknetConv2D_BN_Leaky(256, (1,1)))(x1)#13 y1 = compose( Depthwise_Separable_Conv2D_BN_Leaky(512, (3,3)),#14 DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(x2)#15
The output y1 #16
x3 = compose(#17 DarknetConv2D_BN_Leaky(128, (1,1)),#18 UpSampling2D(2))(x2)#19 x4 = compose( Concatenate(),#20 Depthwise_Separable_Conv2D_BN_Leaky(256, (3,3)))([x3,x1])#21 y2 = compose( DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(x4)#22
The output y2 #23
x5 = compose(#24 DarknetConv2D_BN_Leaky(128, (1,1)),#25 UpSampling2D(2))(x4)#26 x6 = compose( Concatenate(),#27 Depthwise_Separable_Conv2D_BN_Leaky(256, (3,3)))([x5,x11])#28 y3 = compose( DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(x6)#29
The output y3 #30
return Model(inputs, [y1,y2,y2])
Thanks a lot for your answer
I am using your code and I want to change the tiny-yolov3 by adding three Yolo layers instead of two. I want to ask how to change the other files to reflect that because anchor file will contain nine items instead of six, could you help me?
note that i have changed this method to be like this def tiny_yolo3lite_body(inputs, num_anchors, num_classes): '''Create Tiny YOLO_v3 Lite model CNN body in keras.''' x11 = compose( Depthwise_Separable_Conv2D_BN_Leaky(16, (3,3)),#0 MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#1 Depthwise_Separable_Conv2D_BN_Leaky(32, (3,3)),#2 MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#3 Depthwise_Separable_Conv2D_BN_Leaky(64, (3,3)),#4 MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#5 Depthwise_Separable_Conv2D_BN_Leaky(128, (3,3)))(inputs)#6 x1 = compose( MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#7 Depthwise_Separable_Conv2D_BN_Leaky(256, (3,3)))(x11)#8 x2 = compose( MaxPooling2D(pool_size=(2,2), strides=(2,2), padding='same'),#9 Depthwise_Separable_Conv2D_BN_Leaky(512, (3,3)),#10 MaxPooling2D(pool_size=(2,2), strides=(1,1), padding='same'),#11 Depthwise_Separable_Conv2D_BN_Leaky(1024, (3,3)),#12 DarknetConv2D_BN_Leaky(256, (1,1)))(x1)#13 y1 = compose( Depthwise_Separable_Conv2D_BN_Leaky(512, (3,3)),#14 DarknetConv2D(num_anchors*(num_classes+5), (1,1)))(x2)#15
The output y1 #16