Skip to content

Commit

Permalink
Add all files
Browse files Browse the repository at this point in the history
Revert too extreme code clean up
  • Loading branch information
melanibe authored May 27, 2024
1 parent 46b355a commit 5bd5fc9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions data_handling/xray.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,14 @@ def __getitem__(self, idx: int) -> Dict:
).detach()

if self.use_counterfactuals:
cfx = self.load_counterfactual_image(idx)
if not self.counterfactual_contrastive_pairs:
img = cfx.clone()
if self.counterfactual_contrastive_pairs:
cfx = self.load_counterfactual_image(idx)
else:
if torch.rand(1).item() > 0.5:
cfx = self.load_counterfactual_image(idx)
img = cfx.clone()
else:
cfx = img.clone()
img = self.transform(img)
cfx = self.transform(cfx)
img = torch.stack([img, cfx], dim=0).float()
Expand Down

0 comments on commit 5bd5fc9

Please sign in to comment.