Hi
Thanks for your effort,
I tested demo.ipynb and it works properly. But when I change the file mask_rcnn_coco.h5 with my own .h5 that I trained, it gives me the following error.
Any help please ??
ValueError: Dimension 1 in both shapes must be equal, but are 324 and 8. Shapes are [1024,324] and [1024,8]. for 'Assign_682' (op: 'Assign') with input shapes: [1024,324], [1024,8].
You must have trained an two-class classifier (including background) then. Modify the number of classes somewhere.
HI @ShiningCoding
In coco.py there is
# Number of classes (including background)
NUM_CLASSES = 1 + 80 # COCO has 80 classes
For me when I trained it with only one class I worte like this
# Number of classes (including background)
NUM_CLASSES = 1 + 1 # COCO has 1 class
Is this correct ? is this what do you mean ?
Yes, You can try it ( in your own config class in fact). @Abduoit
@ShiningCoding
yes that what I did, I trained it with 1 class + 1 for background
is this what you mean ? could you please explain more ?
Hi,
Although I changed the NUM_CLASSES = 1+1 with same mask_rcnn_coco.h5, I got the similar error as @Abduoit. Is there anything else to modified?
@tsly123
you get this error when you use your own trained file .h5 but what error do you get if you try to replace mask_rcnn_coco.h5 with mask_rcnn_balloon.h5
please check my issue
here and let me know if you are getting same error ??!!
Notice that there is some code in balloon.py
>
print("Loading weights ", weights_path)
if args.weights.lower() == "coco":
# Exclude the last layers because they require a matching
# number of classes
model.load_weights(weights_path, by_name=True, exclude=[
"mrcnn_class_logits", "mrcnn_bbox_fc",
"mrcnn_bbox", "mrcnn_mask"])
else:
model.load_weights(weights_path, by_name=True)
You may try the same way to exclude these last layers in training.
@searchforpassion
do you mean, I have to re-train it again but with removing these lines from the file balloon.py
print("Loading weights ", weights_path)
if args.weights.lower() == "coco":
# Exclude the last layers because they require a matching
# number of classes
model.load_weights(weights_path, by_name=True, exclude=[
"mrcnn_class_logits", "mrcnn_bbox_fc",
"mrcnn_bbox", "mrcnn_mask"])
else:
model.load_weights(weights_path, by_name=True)
you can load weights with this code:
model.load_weights(weights_path, by_name=True, exclude=[ "mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask"])
Changing this
# Number of classes (including background)
NUM_CLASSES = 1 + 80 # COCO has 80 classes
to this
# Number of classes (including background)
NUM_CLASSES = 1 + 1 # COCO has 1 class
does not help. Any other solution?
I use the 2017 MACBOOK. run demo.ipynb, and download mask_rcnn_coco.h5 file. but I get error
ValueError: Dimension 1 in both shapes must be equal, but are 324 and 8. Shapes are [1024,324] and [1024,8]. for 'Assign_682' (op: 'Assign') with input shapes: [1024,324], [1024,8].
Did you train your own h5 file with binary class? If not exclude the fully connected layer at the end when loading the weights
I trained for 3 classes for my own data. But while evaluating I also get a similar error. Any solution for this?
ValueError: Dimension 1 in both shapes must be equal, but are 16 and 12 for 'Assign_682' (op: 'Assign') with input shapes: [1024,16], [1024,12].
@xjNiu 你可以具体说一下 你是如何该的那段段代码么
@Abduoit I also encountered the same error. Did you solve this error?
@xjNiu 你可以具体说一下 你是如何该的那段段代码么
@zhaoyucong "Load weights"
i run the same model in two environnements (my local env and waleedka container ) and it work perefectly in the container but for my local env it raise this issue
replacing the model load with model.load_weights(weights_path, by_name=True, exclude=[
"mrcnn_class_logits", "mrcnn_bbox_fc",
"mrcnn_bbox", "mrcnn_mask"])
but it doesn't detect anything
Xi = np.reshape(X_input, (n_patterns, m_features,1))
model = Sequential()
model.add(LSTM(100, input_shape=(Xi.shape[1],Xi.shape[2]), return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(25, activation='relu', return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(18, activation='relu', return_sequences=False))
model.add(Dropout(0.2))
model.add(Dense(len(mini)+len(minycoord)*2, activation='sigmoid'))
filename = "_five_w24X25x18X21-sigmoid-18761-0.0481-v5.0.hdf5"
model.load_weights(filename)
model.compile(loss='mean_squared_error', optimizer='adam')
This code runs well and does not give any error with 4 layer LSTM N/W. However, if I increase the neurons in middle layers as 45 and 35 respectively and use newly trained weights as below, it gives valueError.
filename = "_five_w24X45x35X21-sigmoid-19459-0.0225-v5.0.hdf5"
model.load_weights(filename)
model.compile(loss='mean_squared_error', optimizer='adam')
Here's the main error message:
ValueError: Dimension 1 in both shapes must be equal, but are 100 and 180. Shapes are [100,100] and [100,180]. for 'Assign_24' (op: 'Assign') with input shapes: [100,100], [100,180].
I'm stuck with this... please explain step by step
Solved!
I was doing a silly thing. I was putting the path of my weights in the comand line, but the correct is put just the word "coco". This way:
python3 talhao.py train --dataset=/path/to/talhao/dataset --weights=coco
Most helpful comment
you can load weights with this code: