手 - 跟踪算法 使用plumber生成SG失败



  • 使用plumber编译tensflow模型,出现问题,请看看是否能解决。

    1. 使用以下tensorflow的ckpt文件
    https://github.com/victordibia/handtracking/tree/master/model-checkpoint
    
    1. 分别下载ckpt, .index, .meta文件,并且拷贝文件进入docker。
    2. 修改脚本路径并且运行1_plumber_freeze.sh 产生model.pb文件。
    3. 修改脚本路径,使用新model.pb产生SG, 运行2_plumber_genSG.sh,会报以下错误:
    2018-10-11 08:15:57 INFO loading TensorFlow model from ./handtracking_out/model.pb ...
    2018-10-11 08:15:57 INFO Initialising with model frozen file ...
    Traceback (most recent call last):
      File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 618, in import_graph_def
        input_type = input_types[i]
    IndexError: list index out of range
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/bin/plumber_cli", line 11, in <module>
        sys.exit(cli())
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
        rv = self.invoke(ctx)
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
        return f(get_current_context(), *args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/plumber_cli.py", line 227, in sg
        input_image_shape=input_image_shape)
      File "/usr/local/lib/python3.5/dist-packages/plumber_cli.py", line 132, in sg_func
        sg = utils.gen_sg(model, input_image_shape=input_image_shape)
      File "plumber/utils.py", line 97, in plumber.utils.gen_sg
      File "plumber/frontend/tf/frontend.py", line 96, in plumber.frontend.tf.frontend.TensorFlowFrontEnd.load
      File "plumber/frontend/tf/model.py", line 56, in plumber.frontend.tf.model.TensorFlowModel.__init__
      File "plumber/frontend/tf/model.py", line 57, in plumber.frontend.tf.model.TensorFlowModel.__init__
      File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
        return func(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 622, in import_graph_def
        % (input_name,)))
    ValueError: graph_def is invalid at node 'cond_7/one_hot/depth': More inputs specified ('cond_7/Switch:1') than the op expects..
    
    
    1. 如果使用已经冻结的.pb文件,在运行2_plumber_genSG.sh后,也会报错,但是报错内容不同。
    https://github.com/victordibia/handtracking/tree/master/hand_inference_graph
    

    报错内容:

    2018-10-11 08:28:23 INFO loading TensorFlow model from ./handtracking_frozen_model/model.pb ...
    2018-10-11 08:28:23 INFO Initialising with model frozen file ...
    2018-10-11 08:28:23 INFO Successfully loaded the model!
    2018-10-11 08:28:23 INFO Rewriting the input TensorFlow Graph for convenient SG generation ...
    2018-10-11 08:28:23 INFO Rewriting the graph by "ReshapeRewriter" ...
    Traceback (most recent call last):
      File "/usr/local/bin/plumber_cli", line 11, in <module>
        sys.exit(cli())
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
        rv = self.invoke(ctx)
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
        return f(get_current_context(), *args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/plumber_cli.py", line 227, in sg
        input_image_shape=input_image_shape)
      File "/usr/local/lib/python3.5/dist-packages/plumber_cli.py", line 132, in sg_func
        sg = utils.gen_sg(model, input_image_shape=input_image_shape)
      File "plumber/utils.py", line 97, in plumber.utils.gen_sg
      File "plumber/frontend/tf/frontend.py", line 118, in plumber.frontend.tf.frontend.TensorFlowFrontEnd.load
      File "plumber/frontend/tf/frontend.py", line 145, in plumber.frontend.tf.frontend.TensorFlowFrontEnd.rewrite_graph
      File "plumber/frontend/tf/graph_rewriter.py", line 416, in plumber.frontend.tf.graph_rewriter.rewrite_reshape_batch_size
      File "plumber/frontend/tf/subgraph_utils.py", line 39, in plumber.frontend.tf.subgraph_utils.find_subgraph_from_graph
      File "plumber/frontend/tf/graph.py", line 197, in plumber.frontend.tf.graph.TFGraph.make_from_graph
      File "plumber/frontend/tf/graph.py", line 189, in plumber.frontend.tf.graph.TFGraph.create_node_map
      File "plumber/frontend/tf/graph.py", line 517, in plumber.frontend.tf.graph.TFGraph._create_edge_maps
    KeyError: '^Preprocessor/map/while/Identity'
    
    


  • @上山打老虎 您好,请问提问的这个问题是否得到解决?如果有其他问题请随时提问



  • @上山打老虎 请看我的这个帖子https://community.corerain.com/topic/58/plumber%E5%8F%AF%E4%BB%A5%E8%A7%A3%E6%9E%90%E7%9A%84%E6%A8%A1%E5%9E%8B%E5%92%8C%E6%A8%A1%E5%9E%8B%E9%80%82%E9%85%8D%E4%BE%8B%E5%AD%90



  • @小神邹
    请问如何判断哪些模型能被Plumber解析,哪些模型不能被Plumber解析。
    有没有一些提供测试的open-source的模型文件?



  • Hi, 目前我知道的情况是由于这个模型的问题,它并不能直接被Plumebr解析, 我看了这个git描述的,它是使用tensorflow下的models库里面的api,你下载的是特定的模型,它有提示:

    Note: The code in this repo is written and tested with Tensorflow 1.4.0-rc0. Using a different version may result in some errors. You may need to generate your own frozen model graph using the model checkpoints in the repo to fit your TF version.

    也就是说这个模型不能直接拿来使用,你需要使用一个脚本来导出新的可用的模型(https://pythonprogramming.net/testing-custom-object-detector-tensorflow-object-detection-api-tutorial/?completed=/training-custom-objects-tensorflow-object-detection-api-tutorial/):

    python3 export_inference_graph.py \
        --input_type image_tensor \
        --pipeline_config_path training/ssd_mobilenet_v1_pets.config \
        --trained_checkpoint_prefix training/model.ckpt-10856 \
        --output_directory mac_n_cheese_inference_graph
    

    请看 https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/exporting_models.md