Are ZoeDepth models traceable?
I was trying to trace ZoeD_NK model and got following error,
File "/home/ketan/ZoeDepth/tracing.py", line 39, in <module>
module = torch.jit.trace(model_zoe_nk, x)
File "/home/ketan/.local/lib/python3.8/site-packages/torch/jit/_trace.py", line 794, in trace
return trace_module(
File "/home/ketan/.local/lib/python3.8/site-packages/torch/jit/_trace.py", line 1056, in trace_module
module._c._create_method_from_trace(
File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1488, in _slow_forward
result = self.forward(*input, **kwargs)
File "/home/ketan/ZoeDepth/zoedepth/models/zoedepth/zoedepth_v1.py", line 144, in forward
rel_depth, out = self.core(x, denorm=denorm, return_rel_depth=True)
File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1488, in _slow_forward
result = self.forward(*input, **kwargs)
File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 264, in forward
x = self.prep(x)
File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 188, in __call__
return self.normalization(self.resizer(x))
File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 174, in __call__
width, height = self.get_size(*x.shape[-2:][::-1])
File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 165, in get_size
new_height = self.constrain_to_multiple_of(scale_height * height)
File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 101, in constrain_to_multiple_of
y = (np.round(x / self.__multiple_of) * self.__multiple_of).astype(int)
AttributeError: 'Tensor' object has no attribute 'astype'
I want to run this model with a cpp script.
you are trying to convert string type to int type but what file are you trying to convert. mention it in parenthesis nest to int like .astype(int)(image)
I was trying to trace ZoeD_NK model and got following error,
File "/home/ketan/ZoeDepth/tracing.py", line 39, in <module> module = torch.jit.trace(model_zoe_nk, x) File "/home/ketan/.local/lib/python3.8/site-packages/torch/jit/_trace.py", line 794, in trace return trace_module( File "/home/ketan/.local/lib/python3.8/site-packages/torch/jit/_trace.py", line 1056, in trace_module module._c._create_method_from_trace( File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1488, in _slow_forward result = self.forward(*input, **kwargs) File "/home/ketan/ZoeDepth/zoedepth/models/zoedepth/zoedepth_v1.py", line 144, in forward rel_depth, out = self.core(x, denorm=denorm, return_rel_depth=True) File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "/home/ketan/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1488, in _slow_forward result = self.forward(*input, **kwargs) File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 264, in forward x = self.prep(x) File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 188, in __call__ return self.normalization(self.resizer(x)) File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 174, in __call__ width, height = self.get_size(*x.shape[-2:][::-1]) File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 165, in get_size new_height = self.constrain_to_multiple_of(scale_height * height) File "/home/ketan/ZoeDepth/zoedepth/models/base_models/midas.py", line 101, in constrain_to_multiple_of y = (np.round(x / self.__multiple_of) * self.__multiple_of).astype(int) AttributeError: 'Tensor' object has no attribute 'astype'I want to run this model with a cpp script.
I encountered this problem, too. Do you fix this?
Would this resolve your issue? by replacing .astype(int) with .int()
Would this resolve your issue? by replacing
.astype(int)with.int()I have solved this problem by editing the source files.