@ranftlr
I try to script "dpt_hybrid-midas-d889a10e.pt" by calling torch.jit.script(model).
But I had trouble trying to convert it .
Could you help me?Thank you.
Traceback (most recent call last):
File "E:/xidian/depth/DPT-main/dpt/convert.py", line 23, in
traced_script_module = torch.jit.script(model)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 943, in script
obj, torch.jit._recursive.infer_methods_to_compile
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 391, in create_script_module
return create_script_module_impl(nn_module, concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 455, in create_script_module_impl
create_hooks_from_stubs(concrete_type, hook_stubs, pre_hook_stubs)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 344, in create_hooks_from_stubs
concrete_type._create_hooks(hook_defs, hook_rcbs, pre_hook_defs, pre_hook_rcbs)
RuntimeError: Hook 'hook' on module 'ResNetStage' expected the input argument to be typed as a Tuple but found type: 'Tensor' instead.
This error occured while scripting the forward hook 'hook' on module ResNetStage. If you did not want to script this hook remove it from the original NN module before scripting. This hook was expected to have the following signature: hook(self, input: Tuple[Tensor], output: Tensor). The type of the output arg is the returned type from either the forward method or the previous hook if it exists. Note that hooks can return anything, but if the hook is on a submodule the outer module is expecting the same return type as the submodule's forward.
@ranftlr I try to script "dpt_hybrid-midas-d889a10e.pt" by calling torch.jit.script(model). But I had trouble trying to convert it . Could you help me?Thank you.
Traceback (most recent call last): File "E:/xidian/depth/DPT-main/dpt/convert.py", line 23, in
traced_script_module = torch.jit.script(model)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 943, in script
obj, torch.jit._recursive.infer_methods_to_compile
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 391, in create_script_module
return create_script_module_impl(nn_module, concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 448, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_script.py", line 391, in _construct
init_fn(script_module)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 428, in init_fn
scripted = create_script_module_impl(orig_value, sub_concrete_type, stubs_fn)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 455, in create_script_module_impl
create_hooks_from_stubs(concrete_type, hook_stubs, pre_hook_stubs)
File "D:\Anaconda\envs\DPT\lib\site-packages\torch\jit_recursive.py", line 344, in create_hooks_from_stubs
concrete_type._create_hooks(hook_defs, hook_rcbs, pre_hook_defs, pre_hook_rcbs)
RuntimeError: Hook 'hook' on module 'ResNetStage' expected the input argument to be typed as a Tuple but found type: 'Tensor' instead.
This error occured while scripting the forward hook 'hook' on module ResNetStage. If you did not want to script this hook remove it from the original NN module before scripting. This hook was expected to have the following signature: hook(self, input: Tuple[Tensor], output: Tensor). The type of the output arg is the returned type from either the forward method or the previous hook if it exists. Note that hooks can return anything, but if the hook is on a submodule the outer module is expecting the same return type as the submodule's forward.