Skip to main content

Pyramid Focus Augmentation: Medical Image Segmentation with Step Wise Focus

Project description

pyra-pytorch

This is a package supporting Pytorch datasets. This implementation is based on the augmentation method discussed in the paper "Pyramid-Focus-Augmentation: Medical Image Segmentation with Step-Wise Focus" (PDF) and the original github repository: PYRA.

@article{thambawita2020pyramid,
  title={Pyramid-Focus-Augmentation: Medical Image Segmentation with Step-Wise Focus},
  author={Thambawita, Vajira and Hicks, Steven and Halvorsen, P{\aa}l and Riegler, Michael A},
  journal={arXiv preprint arXiv:2012.07430},
  year={2020}
}

How to use:

Install the package,

pip install pyra-pytorch

Creating a PYRA augmented dataset:

from pyra_pytorch import PYRADataset

dataset = PYRADataset("./image_path", # image folder
                      "./masks_path", # mask folder - files´s names of this folder should have image names as prefix to find correct image and mask pairs.
                      img_size = 256,  # height and width of image to resize
                      grid_sizes=[2,4,8,16,32,64,128,256] , # Gird sizes to use as grid augmentation. Note that, the image size after resizing ()
                      transforms = None
                      )
'''
./image_path" --> image folder

./masks_path" --> mask folder - files´s names of this folder should have image names as prefix to find correct image and mask pairs.

img_size = 256 --> height and width of image to resize

grid_sizes=[2,4,8,16,32,64,128,256]  --> Gird sizes to use as grid augmentation. Note that, the image size after resizing (in this case, it is 256) shoud be divisible by these grid sizes.

transforms = None --> Other type of transformations using in Pytorch. 

'''

Creating a PYRA augmented dataset using path list files:

from pyra_pytorch import PYRADatasetFromPaths

dataset = PYRADatasetFromPaths("path_to_the_file_with_image_paths", # file containing all image paths
                      "path_to_file_with_mask_paths", # file containing all mask paths - files´s names of this folder should have image names as prefix to find correct image and mask pairs.
                      img_size = 256,  # height and width of image to resize
                      grid_sizes=[2,4,8,16,32,64,128,256] , # Gird sizes to use as grid augmentation. Note that, the image size after resizing ()
                      transforms = None
                      )
'''
path_to_the_file_with_image_paths" --> A file with all paths of images. File should have one path (absolute path) per line. 

path_to_file_with_mask_paths" --> A file with all paths of masks. The file should have one path (absolute path) per line. Please use the image names as prefix for mask's names to find correct mask for correct image.

img_size = 256 --> height and width of image to resize

grid_sizes=[2,4,8,16,32,64,128,256]  --> Gird sizes to use as grid augmentation. Note that, the image size after resizing (in this case, it is 256) shoud be divisible by these grid sizes.

transforms = None --> Other type of transformations using in Pytorch. 

'''

Creating a PYRA augmented dataset using path list files:

from pyra_pytorch import PYRADatasetFromDF

dataset = PYRADatasetFromDF(df, # A dataframe with two colomns: image_path and mask_path. Each column has absolute path of image and maks.
                      img_size = 256,  # height and width of image to resize
                      grid_sizes=[2,4,8,16,32,64,128,256] , # Gird sizes to use as grid augmentation. Note that, the image size after resizing ()
                      transforms = None
                      )
'''
df --> A dataframe with two colomns: image_path and mask_path. Each column has absolute path of image and maks.

img_size = 256 --> height and width of image to resize

grid_sizes=[2,4,8,16,32,64,128,256]  --> Gird sizes to use as grid augmentation. Note that, the image size after resizing (in this case, it is 256) shoud be divisible by these grid sizes.

transforms = None --> Other type of transformations using in Pytorch. 

'''

Sample ipython notebook

notebook

Contact us:

vajira@simula.no | michael@simula.no

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyra-pytorch-1.3.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

pyra_pytorch-1.3.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pyra-pytorch-1.3.0.tar.gz.

File metadata

  • Download URL: pyra-pytorch-1.3.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for pyra-pytorch-1.3.0.tar.gz
Algorithm Hash digest
SHA256 00a69bc689a55de1ac5021edacf3471402d688f196519be3ba7381525cd63c98
MD5 017d065b022aca43ade7e09c5f7c3abb
BLAKE2b-256 eb38a50980031a183c1f6c31a45f612d8e98aa8503c0e28995d47b28d8ca69d1

See more details on using hashes here.

File details

Details for the file pyra_pytorch-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: pyra_pytorch-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for pyra_pytorch-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c142d2c99a838df658ba3ebfb19d595249eb314641569730459afc784d7dd89
MD5 80daddcdd110ee490a1df3ada486e445
BLAKE2b-256 d7355b19c6cfb1da91339015f85c3df077e68f1b4015ddf948d92129671e2245

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page