Closed nrakltx closed 1 year ago
This was solved by adding int()
in L76-77 of midas/vit.py
.
Just for other users, I solved this issue like:
# unflatten = nn.Sequential(
# nn.Unflatten(
# 2,
# torch.Size(
# [
# h // pretrained.model.patch_size[1],
# w // pretrained.model.patch_size[0],
# ]
# ),
# )
# )
if layer_1.ndim == 3:
# layer_1 = unflatten(layer_1)
layer_1 = torch.unflatten(layer_1, 2, torch.Size([h // pretrained.model.patch_size[1], w // pretrained.model.patch_size[0]]))
if layer_2.ndim == 3:
# layer_2 = unflatten(layer_2)
layer_2 = torch.unflatten(layer_2, 2, torch.Size([h // pretrained.model.patch_size[1], w // pretrained.model.patch_size[0]]))
if layer_3.ndim == 3:
# layer_3 = unflatten(layer_3)
layer_3 = torch.unflatten(layer_3, 2, torch.Size([h // pretrained.model.patch_size[1], w // pretrained.model.patch_size[0]]))
if layer_4.ndim == 3:
# layer_4 = unflatten(layer_4)
layer_4 = torch.unflatten(layer_4, 2, torch.Size([h // pretrained.model.patch_size[1], w // pretrained.model.patch_size[0]]))
Hello, I am trying to export MiDaS 3.0 hybrid to ONNX and first to trace it via
torch.jit.trace
. The following snippet failsWith traceback
Before this error the following warnings appear, which might or might not be related
There are some sparse mentions of people managing to convert MiDaS to ONNX but I cannot understand how they managed to do so (most of them do not supply actual code for converting). Furthermore, there seems to be some variance as to which model is exported online -
DPTDepthModel
orMidasNet
- what is the difference between them?I'd very much appreciate some help with this.
Thanks in advance,
N