Skip to content

Argument type for Input generates issues #27

@mosoriob

Description

@mosoriob

Problem

Argument type for InputFile (pathlib.Path) generates issues in some cases.

For example, the function tflite.Interpreter from TensorFlow library excepts a string

'InterpreterWrapper_CreateWrapperCPPFromFile'.
  Possible C/C++ prototypes are:
    tflite::interpreter_wrapper::InterpreterWrapper::CreateWrapperCPPFromFile(char const *,std::vector< std::string > const &,std::string *)

However, ipython2cwl adds the parameter as pathlib.Path. Then, the code is not the same and generates the following issue

tflite::interpreter_wrapper::InterpreterWrapper::tflite_interpreter_wrapper_InterpreterWrapper_CreateWrapperCPPFromFile__SWIG_1(char const *,PyObject *)

Solution

A quick solution can be to change the type of argument but I'm not the effects.

     54     parser.add_argument('--modelPath', type=str, required=True)

Full error

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
/app/cwl/bin/main in <module>
     54     parser.add_argument('--modelPath', type=pathlib.Path, required=True)
     55     args = parser.parse_args()
---> 56     main(cameraType=args.cameraType, siteID=args.siteID, modelPath=args.
     57         modelPath)

/app/cwl/bin/main in main(cameraType, siteID, modelPath)
     29     testObj.urlToImage(imageURL)
     30     testObj.writeImage(imagePath)
---> 31     interpreter = tflite.Interpreter(model_path=modelPath)
     32     interpreter.allocate_tensors()
     33     result, percent = testObj.inference(interpreter)

/srv/conda/envs/notebook/lib/python3.6/site-packages/tflite_runtime/interpreter.py in __init__(self, model_path, model_content, experimental_delegates)
    202       self._interpreter = (
    203           _interpreter_wrapper.InterpreterWrapper_CreateWrapperCPPFromFile(
--> 204               model_path, self._custom_op_registerers))
    205       if not self._interpreter:
    206         raise ValueError('Failed to open {}'.format(model_path))

NotImplementedError: Wrong number or type of arguments for overloaded function 'InterpreterWrapper_CreateWrapperCPPFromFile'.
  Possible C/C++ prototypes are:
    tflite::interpreter_wrapper::InterpreterWrapper::CreateWrapperCPPFromFile(char const *,std::vector< std::string > const &,std::string *)
    tflite::interpreter_wrapper::InterpreterWrapper::tflite_interpreter_wrapper_InterpreterWrapper_CreateWrapperCPPFromFile__SWIG_1(char const *,PyObject *)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions