File size: 369 Bytes
c7f1d48
 
 
 
 
 
 
 
 
be61cf2
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
try:
    import t5
except ImportError:
    pass

try:
    import clip_encoder
except ImportError:
    pass

def build_encoder(name, **kwargs):
    if name.startswith("google"):
        return t5.T5Encoder(name=name, **kwargs)
    elif name.startswith("openclip"):
        _, model, pretrained = name.split("/")
        return clip_encoder.CLIPEncoder(model, pretrained)