def load_latest_weights()

in src/models.py [0:0]


    def load_latest_weights(self, path, optimizer=None, device=0, config=None):
        ckpts = [os.path.join(path, f) for f in sorted(os.listdir(os.path.join(path))) if
                 '.weights' in f and self.name in f and not '_opt.weights' in f]
        if len(ckpts) == 0:
            print("no Checkpoints found")
            if config and config.preTrained and len(config.preTrained) > self.net_idx and config.preTrained[
                self.net_idx].lower() != "none":
                wpath = os.path.join(config.preTrained[self.net_idx], f"{self.name}.weights")
                if os.path.exists(wpath):
                    print("loading pretrained weights")
                    self.load_weights(wpath, device)
                else:
                    print(f"WARNING pretrained weights not found: {wpath}")
                opath = wpath = os.path.join(config.preTrained[self.net_idx], f"{self.name}.optimizer")
                if optimizer is not None and os.path.exists(opath):
                    self.load_optimizer(opath, optimizer, device)
            return 0
        ckpt_path = ckpts[-1]
        epoch = int(ckpt_path.split('.weights')[0].split('_')[-1])

        self.load_weights(ckpt_path, device)

        if optimizer is not None:
            optim_path = f"{ckpt_path.split('.weights')[0]}.optimizer"
            self.load_optimizer(optim_path, optimizer, device)

        return epoch