You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.py 1.2 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. import torch
  3. from mmdet.core import build_assigner, build_sampler
  4. def _dummy_bbox_sampling(proposal_list, gt_bboxes, gt_labels):
  5. """Create sample results that can be passed to BBoxHead.get_targets."""
  6. num_imgs = 1
  7. feat = torch.rand(1, 1, 3, 3)
  8. assign_config = dict(
  9. type='MaxIoUAssigner',
  10. pos_iou_thr=0.5,
  11. neg_iou_thr=0.5,
  12. min_pos_iou=0.5,
  13. ignore_iof_thr=-1)
  14. sampler_config = dict(
  15. type='RandomSampler',
  16. num=512,
  17. pos_fraction=0.25,
  18. neg_pos_ub=-1,
  19. add_gt_as_proposals=True)
  20. bbox_assigner = build_assigner(assign_config)
  21. bbox_sampler = build_sampler(sampler_config)
  22. gt_bboxes_ignore = [None for _ in range(num_imgs)]
  23. sampling_results = []
  24. for i in range(num_imgs):
  25. assign_result = bbox_assigner.assign(proposal_list[i], gt_bboxes[i],
  26. gt_bboxes_ignore[i], gt_labels[i])
  27. sampling_result = bbox_sampler.sample(
  28. assign_result,
  29. proposal_list[i],
  30. gt_bboxes[i],
  31. gt_labels[i],
  32. feats=feat)
  33. sampling_results.append(sampling_result)
  34. return sampling_results

No Description

Contributors (3)