You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-foundry/how-to/healthcare-ai/deploy-medimageparse3d.md
+98-55Lines changed: 98 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ Consume the MedImageParse 3D segmentation model as a REST API, using simple GET
62
62
63
63
```python
64
64
from azure.ai.ml import MLClient
65
-
from azure.identity importDeviceCodeCredential
65
+
from azure.identity importDefaultAzureCredential
66
66
67
67
credential = DefaultAzureCredential()
68
68
@@ -75,17 +75,21 @@ In the deployment configuration, you get to choose authentication method. This e
75
75
76
76
Once the model is deployed, use the following code to send data and retrieve segmentation masks.
77
77
78
-
TODO: the example here follows MedImageParse (2D) where it uses `ml_client_workspace.online_endpoints.invoke` instead of `urllib.request.urlopen` as in this [notebook](https://dev.azure.com/msazuredev/HLS%20AI%20Platform/_git/3dMedImageParseDeployment?path=/notebooks/03.model.endpoint.api.call.ipynb&version=GBmain&line=192&lineEnd=193&lineStartColumn=1&lineEndColumn=1&lineStyle=plain&_a=contents). Verify the correct call pattern.
|`columns`|`list[string]`|Y|`"image"`, `"text"`| An object containing the strings mapping data to inputs passed to the model.|
133
-
|`index`|`integer`|Y| 0 - 256 | Count of inputs passed to the model. You're limited by how much data can be passed in a single POST request, which depends on the size of your images. Therefore, it's reasonable to keep this number in the dozens. |
134
-
|`data`|`list[list[string]]`|Y|""| The list contains the items passed to the model which is defined by the index parameter. Each item is a list of two strings. The order is defined by the `columns` parameter. The `text` string contains the prompt text. The `image` string is the input volume in NIfTI format encoded using base64 and decoded as utf-8 string. The input text is a string containing the target (e.g., organ) to be segmented. |
154
+
|`columns`|`list[string]`|Yes|`"image"`, `"text"`| An object containing the strings mapping data to inputs passed to the model.|
155
+
|`index`|`integer`|Yes| 0 - 256 | Count of inputs passed to the model. You're limited by how much data can be passed in a single POST request, which depends on the size of your images. Therefore, it's reasonable to keep this number in the dozens. |
156
+
|`data`|`list[list[string]]`|Yes|Base64 image + text prompt| The list contains the items passed to the model which is defined by the index parameter. Each item is a list of two strings. The order is defined by the `columns` parameter. The `text` string contains the prompt text. The `image` string is the input volume in NIfTI format encoded using base64 and decoded as utf-8 string. The input text is a string containing the target (e.g., organ) to be segmented. |
135
157
136
158
### Request example
137
159
138
-
**Requesting segmentation of all cells in a pathology image**
160
+
**Requesting segmentation of pancreas**
139
161
```JSON
140
162
{
141
163
"input_data": {
@@ -154,66 +176,87 @@ The `input_data` object contains the following fields:
154
176
155
177
### Response schema
156
178
157
-
Response payload is a list of JSON-formatted strings, each corresponding to a submitted volume. Each string contains a `segmentation_object`object.
179
+
The response is a list of objects. Each object contains the segmentation result for one input. The segmentation mask is encoded as a Base64 string inside a serialized JSON object under the key `nifti_file`.
158
180
159
-
`segmentation_object` contains the following fields:
|`image_features`|`segmentation_mask`| An object representing the segmentation masks for a given image |
164
-
|`text_features`|`list[string]`| List of strings, one per each submitted text string, classifying the segmentation masks into one of 16 biomedical segmentation categories each: `liver`, `lung`, `kidney`, `pancreas`, `heart anatomies`, `brain anatomies`, `eye anatomies`, `vessel`, `other organ`, `tumor`, `infection`, `other lesion`, `fluid disturbance`, `other abnormality`, `histology structure`, `other`|
165
-
166
-
`segmentation_mask` contains the following fields:
|`data`|`string`| A base64-encoded NumPy array containing the one-hot encoded segmentation mask. There could be multiple instances of objects in the returned array. Decode and use `np.frombuffer` to deserialize. The array contains a three-dimensional matrix. The array's size is `1024x1024` (matching the input image dimensions), with the third dimension representing the number of input sentences provided. See the provided [sample notebooks](#learn-more-from-samples) for decoding and usage examples. |
171
-
|`shape`|`list[int]`| A list representing the shape of the array (typically `[NUM_PROMPTS, 1024, 1024]`) |
172
-
|`dtype`|`string`| An instance of the [NumPy dtype class](https://numpy.org/doc/stable/reference/arrays.dtypes.html) serialized to a string. Describes the data packing in the data array. |
The requested segmentation mask is stored in NIfTI, represented by an encoded string.
176
186
177
-
TODO: verify the value of nifti_file is a string or a json object (without the quote).
178
-
```JSON
187
+
```json
179
188
[
180
189
{
181
-
"nifti_file": "{'data': 'H4sIAAAAAAAE...'}"
190
+
"nifti_file": "{\"data\": \"H4sIAAAAAAAE...\"}"
182
191
}
183
192
]
184
193
```
185
194
186
-
TODO: In an [example notebook](https://dev.azure.com/msazuredev/HLS%20AI%20Platform/_git/3dMedImageParseDeployment?path=/notebooks/01.model.packaging.ipynb&version=GBmain&line=314&lineEnd=315&lineStartColumn=1&lineEndColumn=1&lineStyle=plain&_a=contents), `temp_file.flush()` and `os.unlink(temp_file.name)` are commented out. Are these lines needed?
195
+
The `nifti_file` field is a **stringified JSON object**. To decode:
187
196
188
-
The NIfTI file can be obtained by decoding the returned string using a code like
0 commit comments