blob: dca954c328b8a334a465daa83164b141607a8526 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
"""Dino: pretraining of models with self supervision."""
import copy
from functools import wraps, partial
import torch
from torch import nn
import torch.nn.funtional as F
import torchvision.transforms as T
import wandb
from text_recognizer.models.base import LitBaseModel
def singleton(cache_key):
def inner_fn(fn):
@wraps(fn)
def wrapper(self, *args, **kwargs):
instance = getattr(self, cache_key)
if instance is not None:
return instance
instance = fn(self, *args, **kwargs)
setattr(self, cache_key, instance)
return instance
return wrapper
return inner_fn
|