Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
ENH: Adapt HelloWorld to run using the Inference Service (#837)
Browse files Browse the repository at this point in the history
Closes #696.

Changes the HelloWorld model to only use a single channel, as this is
the format that the [Inference
Service](https://github.com/microsoft/InnerEye-Inference/) expects for
its inputs.

As many tests require the 2-channel data, this PR also creates a new
class, `HelloWorld2Channel`, which inherits from `HelloWorld` but uses 2
channels and can be used for testing. This avoids the pain of having to
alter all unit and regression tests that relied on the 2-channel data
and model.

Both models can be trained on the same data, but now the `HelloWorld`
model can be run by the Inference Service.
  • Loading branch information
peterhessey authored Nov 22, 2022
1 parent 8f9d823 commit d902e02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions InnerEye/ML/configs/segmentation/HelloWorld.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ class HelloWorld(SegmentationModelBase):
* If you want to test that your AzureML workspace is working, please follow the instructions in
<repo_root>/docs/hello_world_model.md.
In this example, the model is trained on 2 input image channels channel1 and channel2, and
In this example, the model is trained on 1 input image channels "channel1", and
predicts 2 foreground classes region, region_1.
"""

def __init__(self, **kwargs: Any) -> None:
fg_classes = ["region", "region_1"]
image_channels = kwargs.pop("image_channels", ["channel1"])
super().__init__(
# Data definition - in this section we define where to load the dataset from
local_dataset=full_ml_test_data_path(),
Expand All @@ -45,7 +46,7 @@ def __init__(self, **kwargs: Any) -> None:
architecture="UNet3D",
feature_channels=[4],
crop_size=(64, 64, 64),
image_channels=["channel1", "channel2"],
image_channels=image_channels,
ground_truth_ids=fg_classes,
class_weights=equally_weighted_classes(fg_classes, background_weight=0.02),
mask_id="mask",
Expand Down
13 changes: 10 additions & 3 deletions docs/source/md/hello_world_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,21 @@ A "datastore" in AzureML lingo is an abstraction for the ML systems to access fi
Instructions to create the datastore are given
[in the AML setup instructions](setting_up_aml.md) in step 5.

## Run the HelloWorld model in AzureML
## Train the HelloWorld model in AzureML

Double-check that you have copied your Azure settings into the settings file, as described
[in the AML setup instructions](setting_up_aml.md) in step 6.
Double-check that you have copied your Azure settings into the settings file, as described [in the AML setup instructions](setting_up_aml.md) in step 6.

Then execute:

```shell
conda activate InnerEye
python InnerEye/ML/runner.py --model=HelloWorld --azureml
```

This will submit a training job to your AzureML workspace. You should see a URL for the run output in your terminal. Follow this link to monitor the job in the AzureML portal.

Once the training job completes, it will register a trained HelloWorld model to your workspace. To see this model, navigate to the completed training run and under the "Overview" tab you will see your model and version under "Registered models". It will be in the format `HelloWorld:<Model Version>`.

## (Optional) Run InnerEye-Inference on the HelloWorld model in AzureML

If you wish to faciliate easily running inference on your models, you can set up the [InnerEye-Inference Service](https://github.com/microsoft/InnerEye-Inference/). Follow instructions in the Inference Service README.md to set it up either locally or as an Azure App Service. You will then be able to run the [start](https://github.com/microsoft/InnerEye-Inference/#start) and [monitor](https://github.com/microsoft/InnerEye-Inference/#results) commands, replacing the model name and version with the model trained in the previous step.

0 comments on commit d902e02

Please sign in to comment.