tanakataiki/ssd_kerasV2

SSDLite MobileNetV2

Opened this issue · 14 comments

I ran into a problem while using your videotest_example.py for the ssd300MobileNetV2Lite model:
model = SSD(input_shape, num_classes=NUM_CLASSES)
leads to an error in ssd300MobileNetV2Lite.py
def SSD(input_shape, num_classes):
in line 118
FeatureExtractor=Model(inputs=mobilenetv2.input, outputs=mobilenetv2.get_layer('res_connect_12').output)
error:
ValueError: No such layer: res_connect_12

It seems like res_connect_12 is not a valid name inside the model. The MobileNetV2 model from Keras has indeed different layer names.
Does the videotest_example.py work for you with MobileNetV2?

I ran into the same issue, I tried to fix it by checking the MobileNetV2 layer names from model.summary(), but I am not 100% sure that the residual connection should be made to the following layer.
FeatureExtractor=Model(inputs=mobilenetv2.input,outputs=mobilenetv2.get_layer('block_12_add').output)

Resisual connction is used or was used at that layer.

But you cant use mobilenetv2 rightnow since training was so hard and you need to train first.

Also this implementation version is 2.1.5 so u need to down grade if you use 2.2.0

Hi tanakataiki, thank you for your impressive work. Do you have any plans to improve your repo for SSD300 on MobileNetv2? I am really curious about how better it will perform compared to MobileNet.

The improvement could be for a lot aspects such as parameters change and training.

But i find it hard to train the same issues is on mobilenetv2 caffe version too.

Yet i am also cusios about mobilenetv2 too

Hi tanakataiki, After loading the weight file as per this comment by pirazor ,I get the below error:

ValueError: Layer #73 (named "3_mbox_conf"), weight <tf.Variable '3_mbox_conf/kernel:0' shape=(3, 3, 576, 6) dtype=float32_ref> has shape (3, 3, 576, 6), but the saved weight has shape (63, 576, 3, 3).

My system also has a higher version of Keras (2.2.4) right now and I am downloading 2.1.5 as per your advice, but will downgrading the version also remove the error mentioned above?

I do believe I solved using ssd300MobileNet,
I changed in file videotest_example.py the following code line

# Change this path if you want to use your own trained weights
model.load_weights('./weights_ADL_224_1.02-3.2951.hdf5', by_name=True)

Hi,
I started to use your ssd300MobileNetV2. If found the same error than @msprengholz and @pirazor. However, the remedy to replace res_connect_12 as mentioned by @pirazor looks not correct. I have found in MobileNetV2 documentation at arXiv:1801.04381v4 issued on 21st of March 2019 in paragraph 6.2 that SSDLite should be attached to the expansion layer 15 (not 12). Do you agree?

@MirzaAnoush
Thanks for the imformation as for a architecture , connecting to any expansion layer doesnt matter excecpt accuracy. but I will try it.

And the reason why error occurs as @pirazor mention is that the mobilenetv2 script has changing block name.

Anyway I will try it.

@MirzaAnoush
SSDLite should be attached to the expansion layer 15 (not 12).
The first layer should be from block 12 since there is a small feature do you mean second feature from layer 15?
I currently get it from layer 16 though.

Hi, is there a final verdict as to which layer the SSD should be connected to? documentation seems to indicate block 15 expand relu. Is this correct?

Thanks for the imformation as for a architecture , connecting to any expansion layer doesnt matter excecpt accuracy

Don't think so @tanakataiki , because of the different layer shapes. This can induce some errors in layer output/input compatibility, I guess.

@MirzaAnoush
SSDLite should be attached to the expansion layer 15 (not 12).
The first layer should be from block 12 since there is a small feature do you mean second feature from layer 15?
I currently get it from layer 16 though.

@tanakataiki also check arxiv.org/pdf/1801.04381, where it says:

For MobileNetV2, the first layer of SSDLite is attached to the expansion of layer 15 (with output stride of 16). The second and the rest of SSDLite layers are attached on top of the last layer (with output stride of 32). This setup is consistent with MobileNetV1 as all layers are attached to the feature map of the same output strides.

So, currently, I am having the same problem:

I ran into a problem while using your videotest_example.py for the ssd300MobileNetV2Lite model:
model = SSD(input_shape, num_classes=NUM_CLASSES)
leads to an error in ssd300MobileNetV2Lite.py
def SSD(input_shape, num_classes):
in line 118
FeatureExtractor=Model(inputs=mobilenetv2.input, outputs=mobilenetv2.get_layer('res_connect_12').output)
error:
ValueError: No such layer: res_connect_12

It seems like res_connect_12 is not a valid name inside the model. The MobileNetV2 model from Keras has indeed different layer names.

So, how can we solve that?
I have tried installing Keras 2.1.5 as @tanakataiki mentioned, but got some different issues with Keras.application and thus not even able to import the MobileNetV2 module which is worse than this.

I'm having the same issue with version 2.1.5. Not even able to import MobileNet V2. Anyone has solved it?