Closed jmtatsch closed 7 years ago
I've found some weights over there https://github.com/rykov8/ssd_keras but am unable to load them properly with keras-2.0.5+
Traceback (most recent call last):
File "image_demo.py", line 14, in <module>
model = SSD300(weights_path=weights_path)
File "/home/tatsch/single_shot_multibox_detector/src/models/ssd.py", line 342, in SSD300
model.load_weights(weights_path, by_name=True)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2617, in load_weights
load_weights_from_hdf5_group_by_name(f, self.layers)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 3145, in load_weights_from_hdf5_group_by_name
original_backend)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 3024, in preprocess_weights_for_loading
weights[0] = np.transpose(weights[0], (3, 2, 0, 1))
File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 550, in transpose
return _wrapfunc(a, 'transpose', axes)
File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 67, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 47, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: axes don't match array
and below 2.0.0 - 2.0.4
Traceback (most recent call last):
File "image_demo.py", line 14, in <module>
model = SSD300(weights_path=weights_path)
File "/home/tatsch/single_shot_multibox_detector/src/models/ssd.py", line 342, in SSD300
model.load_weights(weights_path, by_name=True)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2536, in load_weights
load_weights_from_hdf5_group_by_name(f, self.layers)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 3028, in load_weights_from_hdf5_group_by_name
' element(s).')
ValueError: Layer #51 (named "pool6_mbox_loc_flat") expects 0 weight(s), but the saved weights have 2 element(s).
Which version are you using?
Hello, I transformed the weights from the SSD pytorch implementation (since the one in the ssd_keras is an older implementation of SSD). I am working here in this repo to have a clean/easy to use/ SSD since the other repos are either old or difficult to tweak/read.
I am currently testing the metrics of my implementation with the pytorch SSD but there seems to be a problem with the last Detection/nms layer.
I will try to get it working in the upcoming weeks in the meantime I can upload the weights
Good to know. I have similar goals, maybe I can be of help once you have uploaded the weights.
The weights have been uploaded here I would gladly accept any PR. I am working as well in this project for the Robotics team in Bonn Rhein-Sieg, so a good cooperation between several Robotics group would gladly appreciated :)
So you are currently trying to compare the torch outputs to the keras outpus in keras_detection.py? Or what is you current entry point?
Yes, exactly. I have instantiated both networks and I am passing forward to both networks the same image to spot where could the error be happening. I would have to implement nms as they did in the pytorch so I can actually test every step, instead of using the default TF nms. I believe also I would have to re-code the MAP evaluations since the pytorch code is just not well organized.
Which pytorch weights are you working with? From there https://github.com/amdegroot/ssd.pytorch ?
Yes exactly from there SSD300 v2 trained on VOC0712 (original Caffe version) https://s3.amazonaws.com/amdegroot-models/ssd_300_VOC0712.pth
@jmtatsch I got the results from the paper with the pytorch weights, I will now start cleaning the repo ;)
Great, thanks a lot :+1:
Hi Arriaga,
would it be possible to share your pre-trained SSD300_weights.hdf5?
Cheers, Julian