OpenHI Modules

Suggestive annotation module

Neural nets models

class module.suggest.models.VGG(classes)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.GoogLeNet(num_classes=3, aux_logits=True, transform_input=False)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.InceptionA(in_channels, pool_features)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.InceptionB(in_channels)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.InceptionC(in_channels, channels_7x7)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.InceptionD(in_channels)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.InceptionE(in_channels)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.InceptionAux(in_channels, num_classes)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.BasicConv2d(in_channels, out_channels, **kwargs)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class module.suggest.models.MobileNet(classes=3)
forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Prediction functions

module.suggest.predict.predict_grade(data_dir: str, model_fname: str, save_fname: str, classes: int = 3, batch_size: int = 128, use_gpu: bool = True, gpu_id: int = 0)

Use trained model to predict cancer grade.

Parameters
  • data_dir – Directory of the dataset.

  • model_fname – File path of the trained model.

  • save_fname – File path to save the prediction result.

  • classes – Number of cancer grades.

  • batch_size – Testing batch size.

  • use_gpu – Use GPU to predict or not.

  • gpu_id – Device id of GPU.

Training functions

module.suggest.train.train_network(data_dir: str, save_fname: str, classes: int = 3, epoch: int = 100, batch_size: int = 128, learn_rate: float = 0.001, momentum: float = 0.9, use_gpu: bool = True, gpu_id: int = 0)

Train CNN model using given dataset.

Parameters
  • data_dir – Directory of the dataset.

  • save_fname – File path to save the trained model.

  • classes – Number of cancer grades.

  • epoch – Training epoch.

  • batch_size – Training batch size.

  • learn_rate – Learning rate for SGD.

  • momentum – Momentum for SGD.

  • use_gpu – Use GPU to train or not.

  • gpu_id – Device id of GPU.

Returns

Best loss and accuracy of the model.

WSI Downloading from NIH-GDC repository

Data downloading module provides a programmatic interface to download whole-slide images from NIH-GDC. See NIH-GDC API.

module.data_download.download.download_data(input_file_name)

Parse data entry in the input manifest file, create download links, and download WSIs via NIH-GDC API. The data will be saved to a directory (DownloadData/).

Example:

The user should provide the filename of the manifest for this function to work. To run as example, you can use manifest.txt as an example.

download_data('manifest.txt')
Parameters

input_file_name (str) – File name of the manifest file (full path if necessary)

Returns

None