hubconf.py 813 Bytes
Newer Older
Nathan Ng's avatar
Nathan Ng committed
1
2
3
4
5
6
7
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.

Myle Ott's avatar
Myle Ott committed
8
9
import functools

Myle Ott's avatar
Myle Ott committed
10
from fairseq.models import MODEL_REGISTRY
Nathan Ng's avatar
Nathan Ng committed
11
12


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


Myle Ott's avatar
Myle Ott committed
23
24
25
26
27
28
29
30
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