-
Notifications
You must be signed in to change notification settings - Fork 2
/
faiss_assign.py
executable file
·44 lines (33 loc) · 1.28 KB
/
faiss_assign.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
38
39
40
41
42
43
44
import argparse
from lavis.common.dist_utils import init_distributed_mode
from lavis.common.logger import setup_logger
from nice.common.config import Config
from nice.common.utils import setup_seeds
from nice.runners.runner_base import RunnerBase
from nice.tasks import FAISSAssign
def parse_args():
parser = argparse.ArgumentParser(description="Training")
parser.add_argument("--cfg-path", required=True, help="path to configuration file.")
parser.add_argument(
"--options",
nargs="+",
help="override some settings in the used config, the key-value pair "
"in xxx=yyy format will be merged into config file (deprecate), "
"change to --cfg-options instead.",
)
args = parser.parse_args()
return args
def main():
cfg = Config(parse_args())
init_distributed_mode(cfg.run_cfg)
setup_seeds(cfg)
# set after init_distributed_mode() to only log on master.
setup_logger()
cfg.pretty_print()
task = FAISSAssign.setup_task(cfg=cfg)
datasets = task.build_datasets(cfg)
model = task.build_model(cfg)
runner = RunnerBase(cfg=cfg, job_id=None, task=task, model=model, datasets=datasets)
runner.evaluate(skip_reload=True)
if __name__ == "__main__":
main()