Ejemplo n.º 1
0
 def __init__(self, model):
     super().__init__()
     LOGGER.info('Adding AutoShape... ')
     copy_attr(self, model, include=('yaml', 'nc', 'hyp', 'names', 'stride', 'abc'), exclude=())  # copy attributes
     self.dmb = isinstance(model, DetectMultiBackend)  # DetectMultiBackend() instance
     self.pt = not self.dmb or model.pt  # PyTorch model
     self.model = model.eval()
Ejemplo n.º 2
0
 def autoshape(self):  # add autoShape module
     print('Adding autoShape... ')
     m = autoShape(self)  # wrap model
     copy_attr(m,
               self,
               include=('yaml', 'nc', 'hyp', 'names', 'stride'),
               exclude=())  # copy attributes
     return m
Ejemplo n.º 3
0
 def __init__(self, model):
     super().__init__()
     LOGGER.info('Adding AutoShape... ')
     copy_attr(self,
               model,
               include=('yaml', 'nc', 'hyp', 'names', 'stride', 'abc'),
               exclude=())  # copy attributes
     self.model = model.eval()
Ejemplo n.º 4
0
 def autoshape(self):  # add AutoShape module
     logger.info('Adding AutoShape... ')
     m = AutoShape(self)  # wrap model
     copy_attr(m,
               self,
               include=('yaml', 'nc', 'hyp', 'names', 'stride'),
               exclude=())  # copy attributes
     return m
Ejemplo n.º 5
0
 def autoshape(self):  # add autoShape module
     print("Adding autoShape... ")
     m = autoShape(self)  # wrap model
     copy_attr(m,
               self,
               include=("yaml", "nc", "hyp", "names", "stride"),
               exclude=())  # copy attributes
     return m
Ejemplo n.º 6
0
    def load_model(self):
        m = Model(cfg=self.cfg, nc=self.nc)
        ckpt = torch.load(self.weights)['model']  # load checkpoint
        m.load_state_dict(ckpt.state_dict())
        m.names = ckpt.names

        #load detections params
        self._detections_params()
        autoShape.iou = self.iou_thr
        autoShape.conf = self.conf

        #sacado de ultralytics/yolo
        m = m.fuse()
        model = autoShape(m)
        copy_attr(model,
                  m,
                  include=('yaml', 'nc', 'hyp', 'names', 'stride'),
                  exclude=())  # copy attributes
        self.model = model
        self.model.cuda()
        #fp32 to fp16
        if self.half:
            self.model.half()
Ejemplo n.º 7
0
 def ema_update_attr(self, include=(),
                     exclude=("process_group", "reducer")):
     copy_attr(self.ema, self.model, include, exclude)