from .smal_warapper import SMAL from .aves_warapper import AVES from .animerpp import AniMerPlusPlus def load_amr(checkpoint_path): from pathlib import Path from ..configs import get_config model_cfg = str(Path(checkpoint_path).parent / 'config.yaml') model_cfg = get_config(model_cfg, update_cachedir=True) # Override some config values, to crop bbox correctly if (model_cfg.MODEL.BACKBONE.TYPE in ['vith', 'vithmoe']) and ('BBOX_SHAPE' not in model_cfg.MODEL): model_cfg.defrost() assert model_cfg.MODEL.IMAGE_SIZE == 256, f"MODEL.IMAGE_SIZE ({model_cfg.MODEL.IMAGE_SIZE}) should be 256 for ViT backbone" model_cfg.MODEL.BBOX_SHAPE = [192, 256] model_cfg.freeze() # Update config to be compatible with demo if ('PRETRAINED_WEIGHTS' in model_cfg.MODEL.BACKBONE): model_cfg.defrost() model_cfg.MODEL.BACKBONE.pop('PRETRAINED_WEIGHTS') model_cfg.freeze() model = AniMerPlusPlus.load_from_checkpoint(checkpoint_path, strict=False, cfg=model_cfg, map_location="cpu") return model, model_cfg