(w, t=True, idx=None)
| 19 | from timm.layers import resample_patch_embed, resample_abs_pos_embed |
| 20 | |
| 21 | def _n2p(w, t=True, idx=None): |
| 22 | if idx is not None: |
| 23 | w = w[idx] |
| 24 | if w.ndim == 4 and w.shape[0] == w.shape[1] == w.shape[2] == 1: |
| 25 | w = w.flatten() |
| 26 | if t: |
| 27 | if w.ndim == 4: |
| 28 | w = w.transpose([3, 2, 0, 1]) |
| 29 | elif w.ndim == 3: |
| 30 | w = w.transpose([2, 0, 1]) |
| 31 | elif w.ndim == 2: |
| 32 | w = w.transpose([1, 0]) |
| 33 | return torch.from_numpy(w) |
| 34 | |
| 35 | w = np.load(checkpoint_path) |
| 36 | interpolation = 'bilinear' |
no outgoing calls
no test coverage detected