Skip to content

Commit

Permalink
refactors FetalPlaneDataset adding downsampling_factor and tested in …
Browse files Browse the repository at this point in the history
…notebooks (#4)
  • Loading branch information
mxochicale committed Jul 2, 2023
1 parent 1f0bbf2 commit 2ef338b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
14 changes: 9 additions & 5 deletions examples/difussion-super-resolution-gan/DSRGAN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {
"id": "RjqaHOU9UiCn"
},
Expand Down Expand Up @@ -132,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -166,7 +166,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {
"id": "6O8mjlKLI23w"
},
Expand All @@ -179,7 +179,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {
"id": "2HMQVMOsUxqN"
},
Expand Down Expand Up @@ -287,6 +287,9 @@
"# batch_size = 16\n",
"# batch_size = 128\n",
"\n",
"\n",
"downsampling_factor = 2\n",
"\n",
"# # Data augmentation and preprocessing \n",
"# monai_transform_operations=transforms.Compose([\n",
"# transforms.ToTensor(),\n",
Expand Down Expand Up @@ -318,7 +321,8 @@
" #transform=monai_transform_operations,\n",
" transform=transform_operations, \n",
" train=True,\n",
" train_size=256\n",
" train_size=256,\n",
" downsampling_factor=downsampling_factor\n",
" )\n",
"\n",
"train_size = 12\n",
Expand Down
17 changes: 10 additions & 7 deletions examples/preparing_dataset_fetal_planes.ipynb

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions medisynth/medisynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def __init__(self, root_dir, ref,
operator_number=None,
transform=None,
train=None,
train_size=100
train_size=100,
downsampling_factor=2
):
"""
Args:
Expand All @@ -33,6 +34,7 @@ def __init__(self, root_dir, ref,
return image
"""
self.transform = transform
self.downsampling_factor = downsampling_factor
self.root_dir = root_dir
self.ref = pd.read_csv(ref, sep=';')
self.ref = self.ref[self.ref['Plane'] == plane]
Expand Down Expand Up @@ -72,10 +74,9 @@ def __getitem__(self, idx):
image = self.transform(image)

## Make a half sized image for SRGAN
downsampling = 2
ds_image = resize(
image.cpu().numpy(),
(image.shape[0], image.shape[1] / downsampling, image.shape[2] / downsampling)
(image.shape[0], image.shape[1] / self.downsampling_factor, image.shape[2] / self.downsampling_factor)
)
# .cpu().numpy()#TypeError: Cannot interpret 'torch.float32' as a data type

Expand Down

0 comments on commit 2ef338b

Please sign in to comment.