|
#姿态识别部分源码
net = cv.dnn.readNetFromTensorflow("graph_opt.pb")
cap = cv.VideoCapture(args.input if args.input else 0)
# vid_writer = cv.VideoWriter('output.avi',cv.VideoWriter_fourcc('M','J','P','G'), 10, (inWidth,inHeight))
# vid_writer = None
hasFrame, frame = cap.read()
vid_writer = cv.VideoWriter('output.avi',cv.VideoWriter_fourcc('M','J','P','G'), 10, (frame.shape[1],frame.shape[0]))
# fourcc = cv.VideoWriter_fourcc(*"mp4v") ### 默认的mp4输出格式
# writer = cv.VideoWriter("output.mp4", fourcc, 25, (frame.shape[1],frame.shape[0]), True)
while True:
starttime = time.time()
hasFrame, frame = cap.read()
if not hasFrame:
#cv.waitKey(2000)
break
frameWidth = frame.shape[1]
frameHeight = frame.shape[0]
net.setInput(cv.dnn.blobFromImage(frame, 1.0, (inWidth, inHeight), (127.5, 127.5, 127.5), swapRB=True, crop=False))
out = net.forward()
out = out[:, :19, :, :] # MobileNet output [1, 57, -1, -1], we only need the first 19 elements
#在docker 环境 rknn 1.0.0 版本源码
rknn = RKNN()
print('--> config model')
rknn.config(channel_mean_value='127.5 127.5 127.5 128', reorder_channel='0 1 2', quantized_dtype='asymmetric_quantized-u8')
print('done')
# Load tensorflow model
print('--> Loading model')
ret = rknn.load_tensorflow(tf_pb='./graph_opt.pb',
inputs=['FeatureExtractor/human-pose-estimation/human-pose-estimation/input'],
outputs=['concat_1', 'concat'],
input_size_list=[[368,368,3]],
predef_file=None)
if ret != 0:
print('Load model failed!')
exit(ret)
print('done')
执行报错:
--> Loading model
E Catch exception when loading tensorflow model: ./graph_opt.pb!
T Traceback (most recent call last):
T File "rknn/api/rknn_base.py", line 136, in rknn.api.rknn_base.RKNNBase.load_tensorflow
T File "rknn/base/RKNNlib/converter/convert_tf.py", line 102, in rknn.base.RKNNlib.converter.convert_tf.convert_tf.__init__
T File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 50, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.__init__
T File "rknn/base/RKNNlib/converter/tensorflowloader.py", line 65, in rknn.base.RKNNlib.converter.tensorflowloader.TF_Graph_Preprocess.scan_and_optim_graph
T File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/graph_util_impl.py", line 174, in extract_sub_graph
T _assert_nodes_are_present(name_to_node, dest_nodes)
T File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/graph_util_impl.py", line 133, in _assert_nodes_are_present
T assert d in name_to_node, "%s is not in graph" % d
T AssertionError: concat is not in graph
Load model failed!
参照网上脚本解析绘出节点网络图,还是不知填哪个。但rknn 需要的input 和output 参数还是不知填哪个,是否有脚本直接取出这两个参数呢?
|
|