Skip to content

Commit

Permalink
Added the ability to select the config to use in the eval script.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolya committed Aug 6, 2018
1 parent 6afb858 commit 45a73c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
17 changes: 6 additions & 11 deletions data/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,9 @@ def replace(self, new_config_dict):
'type': ResNetBackbone,
'args': ([3, 4, 23, 3],),

'selected_layers': list(range(2, 7)),
'pred_scales': [[1, 2], [2], [2], [2], [2]],
'pred_aspect_ratios': [[[1], [1.05, 0.62]],
[[1.29, 0.79, 0.47, 2.33, 0.27]],
[[1.19, 0.72, 0.43, 2.13, 0.25]],
[[1.34, 0.84, 0.52, 2.38, 0.30]],
[[1.40, 0.95, 0.64, 2.16]]],
'selected_layers': list(range(2, 8)),
'pred_scales': [[1]]*6,
'pred_aspect_ratios': [ [[0.66685089, 1.7073535, 0.87508774, 1.16524493, 0.49059086]] ] * 6,
})

resnet50_backbone = resnet101_backbone.copy({
Expand Down Expand Up @@ -143,11 +139,10 @@ def replace(self, new_config_dict):
'name': 'yolact_resnet101',
'backbone': resnet101_backbone,

'min_size': 400,
'max_size': 600,
'max_size': 550,

'train_masks': True,
'preserve_aspect_ratio': True,
'preserve_aspect_ratio': False,
'use_prediction_module': True,
'use_yolo_regressors': True,
})
Expand All @@ -161,7 +156,7 @@ def replace(self, new_config_dict):
'pred_aspect_ratios': [ [[1], [1, sqrt(2), 1/sqrt(2), sqrt(3), 1/sqrt(3)][:n]] for n in [3, 5, 5, 5, 3, 3] ],
}),

'max_size': 600,
'max_size': 550,

'train_masks': True,
'preserve_aspect_ratio': False,
Expand Down
8 changes: 7 additions & 1 deletion eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from utils.functions import sanitize_coordinates, SavePath
import pycocotools

from data import cfg
from data import cfg, set_cfg

import numpy as np
import torch
Expand Down Expand Up @@ -73,11 +73,16 @@ def str2bool(v):
help='The output file for coco mask results if --coco_results is set.')
parser.add_argument('--max_num_detections', default=100, type=int,
help='The maximum number of detections to consider for each image for mAP scoring. COCO uses 100.')
parser.add_argument('--config', default=None,
help='The config object to use.')

parser.set_defaults(display=False, resume=False, output_coco_json=False, shuffle=False)

args = parser.parse_args()

if args.config is not None:
set_cfg(args.config)

iou_thresholds = [x / 100 for x in range(50, 100, 5)]
coco_cats = [] # Call prep_coco_cats to fill this

Expand Down Expand Up @@ -577,6 +582,7 @@ def evaluate(net, dataset):
if it > 1:
print('Avg FPS: %.4f' % (1 / frame_times.get_avg()))
plt.imshow(np.clip(img_numpy, 0, 1))
plt.title(str(dataset.ids[image_idx]))
plt.show()
else:
if it > 1: fps = 1 / frame_times.get_avg()
Expand Down
7 changes: 5 additions & 2 deletions yolact.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def make_priors(self, conv_h, conv_w):
# +0.5 because priors are in center-size notation
x = (i + 0.5) / conv_w
y = (j + 0.5) / conv_h

for scale, ars in zip(self.scales, self.aspect_ratios):
for ar in ars:
w = scale * ar / conv_w
Expand Down Expand Up @@ -229,8 +229,11 @@ def forward(self, x):
# torch.set_default_tensor_type('torch.cuda.FloatTensor')

x = torch.zeros((1, 3, cfg.max_size, cfg.max_size))

y = net(x)

for p in net.prediction_layers:
print(p.last_conv_size)

print()
for a in y:
print(a.size(), torch.sum(a))
Expand Down

0 comments on commit 45a73c2

Please sign in to comment.