-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval_ensemble.py
35 lines (29 loc) · 1.33 KB
/
eval_ensemble.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
import logging
import argparse
from lib import evaluation
from lib.modules import set_seeds
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--dataset', default='coco',help='coco or f30k')
parser.add_argument('--result1', default='runs/release_weights/coco_butd_grid_bigru/results_coco.npy')
parser.add_argument('--result2', default='runs/release_weights/coco_butd_region_bigru/results_coco.npy')
parser.add_argument('--evaluate_cxc', action='store_true')
parser.add_argument('--seed', default=2022, type=int, help='random seed')
opt = parser.parse_args()
set_seeds(opt.seed)
if opt.dataset == 'coco':
if not opt.evaluate_cxc:
# Evaluate COCO 5-fold 1K
evaluation.eval_ensemble(results_paths=[opt.result1,opt.result2], fold5=True)
evaluation.eval_ensemble(results_paths=[opt.result1,opt.result2], fold5=False)
else:
# Evaluate COCO-trained models on CxC
evaluation.evalrank(opt.model_path, data_path=opt.data_path, split='testall', fold5=True, cxc=True)
elif opt.dataset == 'f30k':
# Evaluate Flickr30K
evaluation.eval_ensemble(results_paths=[opt.result1,opt.result2], fold5=False)
if __name__ == '__main__':
main()