isl-org / MiDaS

Code for robust monocular depth estimation described in "Ranftl et. al., Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer, TPAMI 2022"
MIT License
4.27k stars 599 forks source link

Module Usage #207

Open WASasquatch opened 1 year ago

WASasquatch commented 1 year ago

In prior versions of MiDaS you could just load the models and use them via modules. But now it seems with the new models you're left with only using the CLI script? That's not very conducive with usage. How can I run the latest model within my functions? I see no usage other the cumbersome CLI script

        torch.hub.set_dir(self.midas_dir)
        midas = torch.hub.load("intel-isl/MiDaS", midas_model, trust_repo=True)
        device = torch.device("cuda") if torch.cuda.is_available(
        ) and use_cpu == 'false' else torch.device("cpu")

        midas.to(device).eval()
        midas_transforms = torch.hub.load("intel-isl/MiDaS", "transforms")

        if midas_model == "DPT_Large" or midas_model == "DPT_Hybrid":
            transform = midas_transforms.dpt_transform
        else:
            transform = midas_transforms.small_transform

        # Do some predictions

The issue is PyTorch hub doesn't have the latest models. And even if you have them local, PyTorch Hub doesn't have the right conf

WASasquatch commented 1 year ago

Anyone can help here?

MalekWahidi commented 1 year ago

Same issue please help with this.