augmentations for 16bit grayscaled

This commit is contained in:
2024-04-29 20:57:53 +02:00
parent 9ac5ba921a
commit d92dce3a46
4 changed files with 9 additions and 9 deletions

View File

@ -53,7 +53,7 @@ class DetectionTrainer(BaseTrainer):
def preprocess_batch(self, batch):
"""Preprocesses a batch of images by scaling and converting to float."""
batch['img'] = batch['img'].to(self.device, non_blocking=True).float() / 255
batch['img'] = batch['img'].to(self.device, non_blocking=True).float() / 65535.0 # uint16 to float16
return batch
def set_model_attributes(self):

View File

@ -44,7 +44,7 @@ class DetectionValidator(BaseValidator):
def preprocess(self, batch):
"""Preprocesses batch of images for YOLO training."""
batch['img'] = batch['img'].to(self.device, non_blocking=True)
batch['img'] = (batch['img'].half() if self.args.half else batch['img'].float()) / 255
batch['img'] = (batch['img'].half() if self.args.half else batch['img'].float()) / 65535.0 # uint16 to float16
for k in ['batch_idx', 'cls', 'bboxes']:
batch[k] = batch[k].to(self.device)