MiDaS icon indicating copy to clipboard operation
MiDaS copied to clipboard

Module Usage

Open WASasquatch opened this issue 1 year ago • 2 comments

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 avatar Mar 24 '23 20:03 WASasquatch

Anyone can help here?

WASasquatch avatar Jun 14 '23 07:06 WASasquatch

Same issue please help with this.

MalekWahidi avatar Jul 06 '23 09:07 MalekWahidi