关于keras-yolov3-deepsort的问题
因科研需要,本人最近在跑keras-yolov3代码,本以为很顺利的git一段gihub上的代码简单调试即可。还是我太年轻了,万事开头难啊。下面是我遇到的一些问题,希望可以给你一点帮助,一点信心。科研道路坎坷,贵在坚持啊~
问题一:AttributeError: module 'keras.backend' has no attribute 'get_session'
解决办法:
`from keras import backend as K`
改成:
`from tensorflow.compat.v1.keras import backend as K
问题二:ValueError: Subshape must have computed start >= end since stride is negative, but is 0 and 2 (computed from start 0 and end 9223372036854775807 over shape with rank 2 and stride-1)
解决办法:找到yolo3/model.py
box_xy = (K.sigmoid(feats[..., :2]) + grid) / K.cast(grid_shape[::-1], K.dtype(feats))
box_wh = K.exp(feats[..., 2:4]) * anchors_tensor / K.cast(input_shape[::-1], K.dtype(feats))
改成:
box_xy = (K.sigmoid(feats[..., :2]) + grid) / K.cast(grid_shape[...,::-1], K.dtype(feats))
box_wh = K.exp(feats[..., 2:4]) * anchors_tensor / K.cast(input_shape[...,::-1], K.dtype(feats))
炸眼一看可能看不出,就是把k.cast()里的改成k.cast(×××[…,::-1])
参考网址
[https://stackoverflow.com/questions/57558476/training-a-keras-model-yields-multiple-optimizer-errors]
https://www.cnblogs.com/sherrydatascience/p/13584237.html