diff --git a/cutie/utils/get_default_model.py b/cutie/utils/get_default_model.py index 3fa5e63..bdf91d5 100644 --- a/cutie/utils/get_default_model.py +++ b/cutie/utils/get_default_model.py @@ -20,9 +20,11 @@ def get_default_model() -> CUTIE: cfg['weights'] = os.path.join(weight_dir, 'cutie-base-mega.pth') get_dataset_cfg(cfg) - # Load the network weights - cutie = CUTIE(cfg).cuda().eval() - model_weights = torch.load(cfg.weights) + # Load the network weights (cuda -> mps -> cpu, like interactive_demo.py) + device = ('cuda' if torch.cuda.is_available() else + 'mps' if torch.backends.mps.is_available() else 'cpu') + cutie = CUTIE(cfg).to(device).eval() + model_weights = torch.load(cfg.weights, map_location=device) cutie.load_weights(model_weights) return cutie