build.py 785 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. # -*- coding:utf-8 -*-
  3. from .criterion import SetCriterion
  4. from .yolof import YOLOF
  5. # build YOLOF
  6. def build_yolof(cfg, is_val=False):
  7. # -------------- Build YOLOF --------------
  8. model = YOLOF(cfg = cfg,
  9. num_classes = cfg.num_classes,
  10. conf_thresh = cfg.train_conf_thresh if is_val else cfg.test_conf_thresh,
  11. nms_thresh = cfg.train_nms_thresh if is_val else cfg.test_nms_thresh,
  12. topk = cfg.train_topk if is_val else cfg.test_topk,
  13. )
  14. # -------------- Build Criterion --------------
  15. criterion = None
  16. if is_val:
  17. # build criterion for training
  18. criterion = SetCriterion(cfg)
  19. return model, criterion