Open bessszilard opened 4 years ago
Hello @bessszilard! We check that weights are indeed updated during the conversion, hence the selection of the conv2d_32 layer to monitor that weights at the beginning and end of script are different.
Layer should be selected dynamically instead of hardcoded, and we'll do the fix soon. In the meantime, you can comment L32 and l112-120 locally to avoid the check
Thanks @RaphaelMeudec! I had followed your instruction and it had successfully generated a .h5 file. Although I got invalid results for the predictions with this code:
# Reload model from .h5
model_det = YOLOv4(
input_shape=(HEIGHT, WIDTH, 3),
anchors=YOLOV4_ANCHORS,
num_classes=5,
training=False,
yolo_max_boxes=100,
yolo_iou_threshold=0.5,
yolo_score_threshold=0.5,
weights='/content/yolov4.h5'
)
# Prepare image
image = tf.io.read_file(img_path)
image = tf.image.decode_image(image)
image = tf.image.resize(image, (HEIGHT, WIDTH))
images = tf.expand_dims(image, axis=0) / 255.0
boxes, scores, classes, valid_detections = model.predict(images)
print(valid_detections)
In the end, the valid_detections is [0]
, and the scores are zero as well:
[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0.]]
model.summary output
Model: "YOLOv4"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_8 (InputLayer) [(None, 416, 416, 3) 0
__________________________________________________________________________________________________
CSPDarknet53 (Model) [(None, 52, 52, 256) 26652512 input_8[0][0]
__________________________________________________________________________________________________
YOLOv4_neck (Model) [(None, 52, 52, 128) 15857152 CSPDarknet53[1][0]
CSPDarknet53[1][1]
CSPDarknet53[1][2]
__________________________________________________________________________________________________
YOLOv3_head (Model) [(None, 50, 4), (Non 21515866 YOLOv4_neck[1][0]
YOLOv4_neck[1][1]
YOLOv4_neck[1][2]
==================================================================================================
Total params: 64,025,530
Trainable params: 63,959,226
Non-trainable params: 66,304
__________________________________________________________________________________________________
None
The .weights file is good because I tested it already with the darknet library.
@bessszilard, did you solve this problem, because I have the same issue. Thank a lot!
No I haven't. Meanwhile I moved on other projects, so this was no longer actual.
On Thu, Mar 11, 2021, 1:29 PM Yenhenij Parchevskij @.***> wrote:
@bessszilard https://github.com/bessszilard, did you solve this problem, because I have the same issue. Thank a lot!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sicara/tf2-yolov4/issues/65#issuecomment-796701598, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALP2IWSHVYQHXVHCUMWJWHTTDCZRRANCNFSM4PIROMHQ .
Hello! I am trying to import a custom Yolov4 model with 5 classes. I trained the model with the darknet library. The weights are proper because I have processed with them a video already.
I used this code based on the
convert_darknet_weights
function.And I got this error:
What causes the error?