I completed CNN course several month ago and now would like to run it on my own. I saved the workspace earlier, but the .h5 model file was broken so I had to download weight and convert it to .h5 manually.
I have a problem while trying to run a predict function on a test image and getting the following error:
InvalidArgumentError: Shapes of all inputs must match: values[0].shape = [1,19,19,255] != values[1].shape = [1,38,38,255] [Op:Pack] name: packed
i haven’t read v3 code, but I know it does image sampling at multiple resolutions, and 38 is 2x 19, which is suspicious. I would be shocked if you could directly load weights trained on a v3 network into a v2 model. The network is an entirely different entity: different shapes, different use of anchor boxes, etc.
Some clues about viability of v3->v2 transfer learning I found here from the author of the YOLO papers:
2.3. Predictions Across Scales
YOLOv3 predicts boxes at 3 different scales. Our system extracts features from those scales using a similar concept to feature pyramid networks [8]. From our base feature extractor we add several convolutional layers…In our experiments with COCO [10] we predict 3 boxes at each scale so the tensor is N ×N ×[3∗(4+1+80)], for the 4 bounding box offsets, 1 objectness prediction, and 80 class predictions.
… 2.4. Feature Extractor
We use a new network for performing feature extraction. Our new network is a hybrid approach between the network used in YOLOv2, Darknet-19, and that newfangled residual network stuff. Our network uses successive 3 × 3 and 1 × 1 convolutional layers but now has some shortcut connections as well and is significantly larger. It has 53 convolutional layers …
V2 had 19 Convolutional layers plus some skip connection voodoo, so I think v3 weights will never work with a v2 model. I am trying to train a v2 at home right now but it is not going flawlessly. Or quickly. Two steps forward, then a big one back…
yep I saw this link already. it looks like there is a problem with the compatibility between keras and tf.
Could you please tell which versions do you have ?
that thread was hijacked with a few different scenarios, but my takeaway was the problem was related to differences in python version, not Keras or tf. Though maybe all three.
regardless, it doesn’t matter what i am running since i am building everything myself. I think instead what matters is that you replicate the environment from which the model/weights file was created. For the record, i am developing in python 3.7.10, tensorflow 2.0.0, and Keras 2.2.4