ultralytics 8.0.172 faster LetterBox() and Classify Tune fix (#4766)

Co-authored-by: BardJun <70683507+jy1002@users.noreply.github.com>
This commit is contained in:
Glenn Jocher 2023-09-06 22:00:04 +02:00 committed by GitHub
parent 577d066fb2
commit 8fd9a1a048
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 26 deletions

View file

@ -48,11 +48,11 @@ class Predictor(BasePredictor):
im = np.ascontiguousarray(im) # contiguous
im = torch.from_numpy(im)
img = im.to(self.device)
img = img.half() if self.model.fp16 else img.float() # uint8 to fp16/32
im = im.to(self.device)
im = im.half() if self.model.fp16 else im.float() # uint8 to fp16/32
if not_tensor:
img = (img - self.mean) / self.std
return img
im = (im - self.mean) / self.std
return im
def pre_transform(self, im):
"""
@ -64,8 +64,9 @@ class Predictor(BasePredictor):
Returns:
(list): A list of transformed images.
"""
assert len(im) == 1, 'SAM model has not supported batch inference yet!'
return [LetterBox(self.args.imgsz, auto=False, center=False)(image=x) for x in im]
assert len(im) == 1, 'SAM model does not currently support batched inference'
letterbox = LetterBox(self.args.imgsz, auto=False, center=False)
return [letterbox(image=x) for x in im]
def inference(self, im, bboxes=None, points=None, labels=None, masks=None, multimask_output=False, *args, **kwargs):
"""