hubconf.py 705 Bytes
Newer Older
1
# Copyright (c) Facebook, Inc. and its affiliates.
Nathan Ng's avatar
Nathan Ng committed
2
#
3
4
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
Nathan Ng's avatar
Nathan Ng committed
5

Myle Ott's avatar
Myle Ott committed
6
7
import functools

Myle Ott's avatar
Myle Ott committed
8
from fairseq.models import MODEL_REGISTRY
Nathan Ng's avatar
Nathan Ng committed
9
10


Myle Ott's avatar
Myle Ott committed
11
12
dependencies = [
    'regex',
Myle Ott's avatar
Myle Ott committed
13
    'requests',
Myle Ott's avatar
Myle Ott committed
14
15
16
17
18
    'sacremoses',
    'sentencepiece',
    'subword_nmt',
    'torch',
]
Nathan Ng's avatar
Nathan Ng committed
19
20


Myle Ott's avatar
Myle Ott committed
21
22
23
24
25
26
27
28
for model_type, _cls in MODEL_REGISTRY.items():
    for model_name in _cls.hub_models().keys():
        globals()[model_name] = functools.partial(
            _cls.from_pretrained,
            model_name_or_path=model_name,
        )
    # to simplify the interface we only expose named models
    #globals()[model_type] = _cls.from_pretrained