mirror of
https://github.com/Laurent2916/REVA-QCAV.git
synced 2024-11-09 23:12:05 +00:00
feat: got precision 16 back
Former-commit-id: 6b19dc9bd17078bb2c151d5cd96e7ba4da9e1b89 [formerly 5d1eac2ed10be960c89407ad265ff350e11c1adf] Former-commit-id: 1db4ca0ce11ac818408b94625b872c1202b5d4ed
This commit is contained in:
parent
ed07e130e6
commit
82682ceeb2
|
@ -58,7 +58,7 @@ class LabeledDataset(Dataset):
|
||||||
|
|
||||||
# open and convert mask
|
# open and convert mask
|
||||||
mask_path = self.images[index].parent.joinpath("MASK.PNG")
|
mask_path = self.images[index].parent.joinpath("MASK.PNG")
|
||||||
mask = np.array(Image.open(mask_path).convert("L"), dtype=np.uint8) / 255
|
mask = np.array(Image.open(mask_path).convert("L"), dtype=np.uint8) // 255
|
||||||
|
|
||||||
# convert image & mask to Tensor float in [0, 1]
|
# convert image & mask to Tensor float in [0, 1]
|
||||||
post_process = A.Compose(
|
post_process = A.Compose(
|
||||||
|
@ -72,4 +72,8 @@ class LabeledDataset(Dataset):
|
||||||
image = augmentations["image"]
|
image = augmentations["image"]
|
||||||
mask = augmentations["mask"]
|
mask = augmentations["mask"]
|
||||||
|
|
||||||
|
# make sure image and mask are floats, TODO: mettre dans le post_process, ToFloat Image only
|
||||||
|
image = image.float()
|
||||||
|
mask = mask.float()
|
||||||
|
|
||||||
return image, mask
|
return image, mask
|
||||||
|
|
|
@ -38,7 +38,7 @@ if __name__ == "__main__":
|
||||||
# model.load_state_dict(state_dict)
|
# model.load_state_dict(state_dict)
|
||||||
|
|
||||||
# log gradients and weights regularly
|
# log gradients and weights regularly
|
||||||
logger.watch(model, log="all")
|
logger.watch(model.model, log="all")
|
||||||
|
|
||||||
# Create the dataloaders
|
# Create the dataloaders
|
||||||
datamodule = Spheres()
|
datamodule = Spheres()
|
||||||
|
@ -49,7 +49,7 @@ if __name__ == "__main__":
|
||||||
accelerator=wandb.config.DEVICE,
|
accelerator=wandb.config.DEVICE,
|
||||||
benchmark=wandb.config.BENCHMARK,
|
benchmark=wandb.config.BENCHMARK,
|
||||||
# profiler="simple",
|
# profiler="simple",
|
||||||
# precision=16,
|
precision=16,
|
||||||
logger=logger,
|
logger=logger,
|
||||||
log_every_n_steps=1,
|
log_every_n_steps=1,
|
||||||
val_check_interval=100,
|
val_check_interval=100,
|
||||||
|
|
|
@ -38,7 +38,7 @@ class UNetModule(pl.LightningModule):
|
||||||
|
|
||||||
# forward pass, compute masks
|
# forward pass, compute masks
|
||||||
prediction = self.model(data)
|
prediction = self.model(data)
|
||||||
binary = (torch.sigmoid(prediction) > 0.5).float() # TODO: check if float necessary
|
binary = (torch.sigmoid(prediction) > 0.5).half()
|
||||||
|
|
||||||
# compute metrics (in dictionnary)
|
# compute metrics (in dictionnary)
|
||||||
metrics = {
|
metrics = {
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TableLog(Callback):
|
||||||
zip(
|
zip(
|
||||||
images.cpu(),
|
images.cpu(),
|
||||||
ground_truth.cpu(),
|
ground_truth.cpu(),
|
||||||
predictions["linear"].cpu(),
|
predictions["linear"].cpu().float(),
|
||||||
predictions["binary"].cpu().squeeze(1).int().numpy(),
|
predictions["binary"].cpu().squeeze(1).int().numpy(),
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
|
|
|
@ -87,7 +87,7 @@ class RandomPaste(A.DualTransform):
|
||||||
|
|
||||||
img.paste(paste_img, (x, y), paste_mask)
|
img.paste(paste_img, (x, y), paste_mask)
|
||||||
|
|
||||||
return np.asarray(img.convert("RGB"))
|
return np.array(img.convert("RGB"))
|
||||||
|
|
||||||
def apply_to_mask(self, mask, augmentations, paste_mask, **params):
|
def apply_to_mask(self, mask, augmentations, paste_mask, **params):
|
||||||
# convert mask to Image, needed for `paste` function
|
# convert mask to Image, needed for `paste` function
|
||||||
|
@ -116,7 +116,7 @@ class RandomPaste(A.DualTransform):
|
||||||
|
|
||||||
mask.paste(paste_mask, (x, y), paste_mask_bin)
|
mask.paste(paste_mask, (x, y), paste_mask_bin)
|
||||||
|
|
||||||
return np.asarray(mask.convert("L"))
|
return np.array(mask.convert("L"))
|
||||||
|
|
||||||
def get_params_dependent_on_targets(self, params):
|
def get_params_dependent_on_targets(self, params):
|
||||||
# choose a random image and its corresponding mask
|
# choose a random image and its corresponding mask
|
||||||
|
|
Loading…
Reference in a new issue