I got the following error when I run python3 export.py --with-camera
UniDepth_v2_vitl14 is loaded with:
missing keys: []
additional keys: []
/raid/alperen/temp/UniDepth/unidepth/models/backbones/metadinov2/patch_embed.py:76: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
H % patch_H == 0
/raid/alperen/temp/UniDepth/unidepth/models/backbones/metadinov2/patch_embed.py:79: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
W % patch_W == 0
/raid/alperen/temp/UniDepth/unidepth/models/backbones/dinov2.py:267: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if npatch == N and w == h:
/raid/alperen/temp/UniDepth/unidepth/models/backbones/dinov2.py:276: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
M = int(math.sqrt(N)) # Recover the number of patches in each dimension
/raid/alperen/temp/UniDepth/unidepth/models/backbones/dinov2.py:277: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert N == M * M
/raid/alperen/temp/UniDepth/unidepth/models/backbones/dinov2.py:295: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert (w0, h0) == patch_pos_embed.shape[-2:]
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:435: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
level_shapes = sorted(
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:454: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
features_splits = torch.tensor(
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:454: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
features_splits = torch.tensor(
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:27: TracerWarning: Converting a tensor to a Python list might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
xs = torch.split(x, splits.int().tolist(), dim=-1)
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:375: TracerWarning: Using len to get tensor shape might cause the trace to be incorrect. Recommended usage would be tensor.shape[0]. Passing a tensor of different shape might lead to errors or silently give incorrect results.
features = torch.chunk(features_projected, len(splits), dim=-1)
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:380: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
cls_tokens_splits = torch.tensor(
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:380: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
cls_tokens_splits = torch.tensor(
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:389: TracerWarning: Using len to get tensor shape might cause the trace to be incorrect. Recommended usage would be tensor.shape[0]. Passing a tensor of different shape might lead to errors or silently give incorrect results.
torch.chunk(cls_tokens, len(cls_tokens_splits), dim=-1), dim=1
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:396: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
intrinsics[:, 0, 0] = max(original_shapes) / 2 * intrinsics[:, 0, 0]
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:397: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
intrinsics[:, 1, 1] = max(original_shapes) / 2 * intrinsics[:, 1, 1]
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:410: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
cls_tokens_splits = torch.tensor(
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:410: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
cls_tokens_splits = torch.tensor(
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:419: TracerWarning: Using len to get tensor shape might cause the trace to be incorrect. Recommended usage would be tensor.shape[0]. Passing a tensor of different shape might lead to errors or silently give incorrect results.
torch.chunk(cls_tokens, len(cls_tokens_splits), dim=-1), dim=1
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:117: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
max_freq=max(shapes) // 2,
/raid/alperen/temp/UniDepth/unidepth/utils/positional_embedding.py:232: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
0.0, log2(max_freq), steps=num_bands, device=device, dtype=dtype
/raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:243: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
max_freq=max(shapes) // 2,
/opt/conda/lib/python3.10/site-packages/xformers/components/attention/nystrom.py:217: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if self.num_landmarks >= seq_len:
/opt/conda/lib/python3.10/site-packages/xformers/components/attention/core.py:217: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
q = q / math.sqrt(k.size(-1))
/opt/conda/lib/python3.10/site-packages/torch/onnx/_internal/jit_utils.py:307: UserWarning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied. (Triggered internally at ../torch/csrc/jit/passes/onnx/constant_fold.cpp:179.)
_C._jit_pass_onnx_node_shape_type_inference(node, params_dict, opset_version)
Traceback (most recent call last):
File "/raid/alperen/temp/UniDepth/export.py", line 226, in <module>
export(
File "/raid/alperen/temp/UniDepth/export.py", line 154, in export
torch.onnx.export(
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/utils.py", line 516, in export
_export(
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/utils.py", line 1613, in _export
graph, params_dict, torch_out = _model_to_graph(
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/utils.py", line 1139, in _model_to_graph
graph = _optimize_graph(
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/utils.py", line 677, in _optimize_graph
graph = _C._jit_pass_onnx(graph, operator_export_type)
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/utils.py", line 1957, in _run_symbolic_function
return symbolic_fn(graph_context, *inputs, **attrs)
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 395, in wrapper
return fn(g, *args, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 289, in wrapper
args = [
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 290, in <listcomp>
_parse_arg(arg, arg_desc, arg_name, fn_name) # type: ignore[assignment]
File "/opt/conda/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 107, in _parse_arg
raise errors.SymbolicValueError(
torch.onnx.errors.SymbolicValueError: Failed to export a node '%6173 : Long(device=cpu) = onnx::Gather[axis=0](%6170, %6172), scope: __main__.UniDepthV2wCamONNX::/unidepth.models.unidepthv2.decoder.Decoder::pixel_decoder # /raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:508:0
' (in list node %6182 : int[] = prim::ListConstruct(%6173, %6177, %6181), scope: __main__.UniDepthV2wCamONNX::/unidepth.models.unidepthv2.decoder.Decoder::pixel_decoder
) because it is not constant. Please try to make things (e.g. kernel sizes) static if possible. [Caused by the value '6182 defined in (%6182 : int[] = prim::ListConstruct(%6173, %6177, %6181), scope: __main__.UniDepthV2wCamONNX::/unidepth.models.unidepthv2.decoder.Decoder::pixel_decoder
)' (type 'List[int]') in the TorchScript graph. The containing node has kind 'prim::ListConstruct'.]
Inputs:
#0: 6173 defined in (%6173 : Long(device=cpu) = onnx::Gather[axis=0](%6170, %6172), scope: __main__.UniDepthV2wCamONNX::/unidepth.models.unidepthv2.decoder.Decoder::pixel_decoder # /raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:508:0
) (type 'Tensor')
#1: 6177 defined in (%6177 : Long(device=cpu) = onnx::Gather[axis=0](%6174, %6176), scope: __main__.UniDepthV2wCamONNX::/unidepth.models.unidepthv2.decoder.Decoder::pixel_decoder # /raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:508:0
) (type 'Tensor')
#2: 6181 defined in (%6181 : Long(device=cpu) = onnx::Gather[axis=0](%6178, %6180), scope: __main__.UniDepthV2wCamONNX::/unidepth.models.unidepthv2.decoder.Decoder::pixel_decoder # /raid/alperen/temp/UniDepth/unidepth/models/unidepthv2/decoder.py:508:0
) (type 'Tensor')
Outputs:
#0: 6182 defined in (%6182 : int[] = prim::ListConstruct(%6173, %6177, %6181), scope: __main__.UniDepthV2wCamONNX::/unidepth.models.unidepthv2.decoder.Decoder::pixel_decoder
) (type 'List[int]')
I got the following error when I run python3 export.py --with-camera