-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 8) dtype=float32_ref> has shape (1024, 8), but the saved weight has shape (1024, 324) #849
Comments
There are 80+1 classes in coco dataset, while you only get 2 classes. So when loading weights you should exclude some layers such as 'mrcnn_bbox_fc','mrcnn_class_logits’(fill the layer's name in the load_weights method), then start fine-tuning. |
@Alexlastname, OK, I did it as you told me , the error was resolved, Thank you very much! |
Hi, I trained the model with my dataset (it worked). I get the same error. How can it work for training but not for predicting? |
@694376965 load_weights方法在那个文件夹下 |
您能详细的说一下么 我还是没有明白 |
您能说一下你解决的详细步骤么 |
@zhaoyucong I had the same problem. After searching for a while I found that when you want to fine-tune, you have to specify in "load_weights()" the parameter "by_name=True" in order to be able to use only some common layers (https://keras.io/models/about-keras-models/). In my case that was not enough, and I added the following: Hope it helps |
@citlag Thanks. I do it as you told me. However, the result isn't which I want to see. The result is many cars which are boxed and named 'person'. It isn't correct cause the class i want to detect is person. |
@zhaoyucong 请问你的问题解决了吗,现在我也遇到同样的问题。 |
model.load_weights(filepath, by_name=True, exclude=[ "mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask"]) |
I trained it and had no problem, but when I want to predict I get this error. I do have Anyone who was able to solve it? (Only in English please) |
@eyildiz-ugoe did you find a solution for this issue ?? |
I don't understand well the answer above (I am new on this). Can somebody shed some lights in how to applied that ("fill the layer's name in the load_weights method") Thanks |
the same issue here. while training i did like model.load_weights(weights_path, by_name=True, exclude=["mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask"]). |
I get the same error while training it. Has anyone resolved this issue? |
Solved; |
I think I found another possible disconnect for people following the balloon sample README. Notice the comment on this page: These are the training arguments described on the balloon sample page:
But even though the training will succeed, it produces the incorrect result when using the newly trained model to predict. Instead, you should train by downloading mask_rcnn_coco.h5 from the 2.0 release and changing the arguments to:
You still need to change the model.load_weights call to exclude the other layers as @zdforient mentioned. |
thank you, the error was resolved~ |
@zhaoyucong @Alexlastname @KanchanIIT not producing the correct results, you are solved the issue? |
how you solve this |
Load weights
above code is a part of program and because of this running the program but not producing the masked result images. anyone solved the problem of this issue? @Alexlastname @zdforient @BelhalK @zhaoyucong @waleedka @PavlosMelissinos @rymalia @moorage done exactly same but the result is saving in png image file but no masked image result for a |
I have done same as you told solution 1, it is working but the result is in non-masked image for damage part of car, means result is same as input image. for solution 2, in the code where I have to change name from ""mask_rcnn_coco.h5"" to ""coco"" ? |
I meet the same problem just like |
Hi, when I use the exclude, it throws the following message: |
I still cant figure out a working solution from all the above discussion. Anybody out there to rescue?? Atleast please explain how to append the classes number in model.py |
it works thanks! |
i am also gettting same error when usin resnet152 how to resolve it.. ValueError: Layer #24 (named "res2b_branch2a"), weight <tf.Variable 'res2b_branch2a/kernel:0' shape=(1, 1, 512, 64) dtype=float32> has shape (1, 1, 512, 64), but the saved weight has shape (64, 256, 1, 1). |
oj8k |
Do you modify the width/height for the anchor |
I have solved the kind of issue as follows. Hope the solution would be helpful. Delete "by_name=True"
|
You can exclude these layers as given below:instead of
|
Hi! but the following error pops up:
Has someone achieved to solve this issue? |
hello! |
I have the same error, use exclude will affect the result because on the other laptop (windows, it worked fine without exclude and with exclude my results are messed up), but on Ubuntu Linux, it get this error |
I was having the same problem after changing the name in my extended configuration to be |
Hi, I followed this guidance. It has worked, however the result was not correct. |
Switched to YoloV4 |
I have the same issue here. Were you able to resolve this problem? |
Refer to # #2252 Actually I changed |
I have a question. Excluding some layers, Are these layers not able to training ? |
Okay so what worked for me after trying different solutions was a hit a
trial thing that I figured out and that is, if you have been using the
mask_rcnn_balloon.h5 file while running the program, there are three
versions of this file on the release page try to download the mask_rcnn 1.0
coco.h5 file or the mask_rcnn 2.0 coco.h5 file. It worked for me
|
But in my case, crack detection, it made the crack detection itself producing incorrect output compared to the demo |
did you solve it? how? |
For me this was the exact problem, the trick is to choose the model.h5 file from ""C:\Users\Username\Desktop\Python Projects\Curveball\MaskRcnn\logs\object20220131T0046\mask_rcnn_object_0020.h5"" and not the saved model as entered by you. |
I do have model.load_weights(weights_path, by_name=True, exclude=["mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask"]) line and I still get this Layer #389 error. Anyone was able to solve it? kindly shed some light. |
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
|
If you are loading the weights before re-training, then for sure you need to have |
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
|
This worked! |
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
|
hi, when I loaded all the files down, I can run the balloon demo to detect balloon correctly.
But, when I want to train a new model with the given balloon data set according to the steps given, there was an error:
Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 8) dtype=float32_ref> has shape (1024, 8), but the saved weight has shape (1024, 324)
Can some one help me?
I used the mask_rcnn_coco.h5 as the pretrained model.
python3 balloon.py train --dataset=/opt/projects/samples/balloon/balloonImages/datasets/ --weights=/opt/projects/samples/balloon/mask_rcnn_coco.h5
Using TensorFlow backend.
Weights: /opt/projects/samples/balloon/mask_rcnn_coco.h5
Dataset: /opt/projects/samples/balloon/balloonImages/datasets/
Logs: /opt/projects/logs_balloon
<main.BalloonConfig object at 0x7efb9d8cc898>
Configurations:
BACKBONE resnet101
BACKBONE_STRIDES [4, 8, 16, 32, 64]
BATCH_SIZE 2
BBOX_STD_DEV [0.1 0.1 0.2 0.2]
COMPUTE_BACKBONE_SHAPE None
DETECTION_MAX_INSTANCES 100
DETECTION_MIN_CONFIDENCE 0.9
DETECTION_NMS_THRESHOLD 0.3
FPN_CLASSIF_FC_LAYERS_SIZE 1024
GPU_COUNT 1
GRADIENT_CLIP_NORM 5.0
IMAGES_PER_GPU 2
IMAGE_MAX_DIM 1024
IMAGE_META_SIZE 14
IMAGE_MIN_DIM 800
IMAGE_MIN_SCALE 0
IMAGE_RESIZE_MODE square
IMAGE_SHAPE [1024 1024 3]
LEARNING_MOMENTUM 0.9
LEARNING_RATE 0.001
LOSS_WEIGHTS {'rpn_class_loss': 1.0, 'rpn_bbox_loss': 1.0, 'mrcnn_class_loss': 1.0, 'mrcnn_bbox_loss': 1.0, 'mrcnn_mask_loss': 1.0}
MASK_POOL_SIZE 14
MASK_SHAPE [28, 28]
MAX_GT_INSTANCES 100
MEAN_PIXEL [123.7 116.8 103.9]
MINI_MASK_SHAPE (56, 56)
NAME balloon
NUM_CLASSES 2
POOL_SIZE 7
POST_NMS_ROIS_INFERENCE 1000
POST_NMS_ROIS_TRAINING 2000
ROI_POSITIVE_RATIO 0.33
RPN_ANCHOR_RATIOS [0.5, 1, 2]
RPN_ANCHOR_SCALES (32, 64, 128, 256, 512)
RPN_ANCHOR_STRIDE 1
RPN_BBOX_STD_DEV [0.1 0.1 0.2 0.2]
RPN_NMS_THRESHOLD 0.7
RPN_TRAIN_ANCHORS_PER_IMAGE 256
STEPS_PER_EPOCH 100
TOP_DOWN_PYRAMID_SIZE 256
TRAIN_BN False
TRAIN_ROIS_PER_IMAGE 200
USE_MINI_MASK True
USE_RPN_ROIS True
VALIDATION_STEPS 50
WEIGHT_DECAY 0.0001
Loading weights /opt/projects/samples/balloon/mask_rcnn_coco.h5
<HDF5 file "mask_rcnn_coco.h5" (mode r)>
Traceback (most recent call last):
File "balloon.py", line 357, in
model.load_weights(weights_path, by_name=True)
File "/opt/projects/mrcnn/model.py", line 2140, in load_weights
reshape=False)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 1017, in load_weights_from_hdf5_group_by_name
str(weight_values[i].shape) + '.')
ValueError: Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 8) dtype=float32_ref> has shape (1024, 8), but the saved weight has shape (1024, 324).
The text was updated successfully, but these errors were encountered: