forked from facebookresearch/vissl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnearest_neighbor_test.py
37 lines (28 loc) · 1.08 KB
/
nearest_neighbor_test.py
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
29
30
31
32
33
34
35
36
37
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import sys
from argparse import Namespace
from typing import Any, List
from vissl.config import AttrDict
from vissl.utils.hydra_config import compose_hydra_configuration, convert_to_attrdict
from vissl.utils.knn_utils import (
extract_features_and_run_knn,
extract_features_and_run_knn_on_slurm,
)
from vissl.utils.slurm import is_submitit_available
def main(args: Namespace, config: AttrDict):
if config.SLURM.USE_SLURM:
assert (
is_submitit_available()
), "Please 'pip install submitit' to schedule jobs on SLURM"
extract_features_and_run_knn_on_slurm(config)
else:
extract_features_and_run_knn(args.node_id, config)
def hydra_main(overrides: List[Any]):
cfg = compose_hydra_configuration(overrides)
args, config = convert_to_attrdict(cfg)
main(args, config)
if __name__ == "__main__":
overrides = sys.argv[1:]
hydra_main(overrides=overrides)