Skip to content

Commit 9a358aa

Browse files
authored
Update how-to-batch-scoring-script.md
1 parent 54e472b commit 9a358aa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

articles/machine-learning/how-to-batch-scoring-script.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Your deployment configuration controls the size of each mini-batch and the numbe
156156

157157
### Using models that are folders
158158

159-
The environment variable `AZUREML_MODEL_DIR` is typically used in the `init()` function to load the model. However, some models may contain its files inside of a folder. When reading the files in this variable, you may need to account for that. You can identify the folder where your MLflow model is placed as follows:
159+
The environment variable `AZUREML_MODEL_DIR` is typically used in the `init()` function of your scoring script to load the model. However, some models may contain its files inside of a folder. When reading the files in this variable, you may need to account for that. You can identify the folder where your MLflow model is placed as follows:
160160

161161
1. Go to [Azure Machine Learning portal](https://ml.azure.com).
162162

@@ -171,7 +171,14 @@ The environment variable `AZUREML_MODEL_DIR` is typically used in the `init()` f
171171
Then you can use this path to load the model:
172172

173173
```python
174-
model_path = os.path.join(os.environ["AZUREML_MODEL_DIR"], "model")
174+
def init():
175+
global model
176+
177+
# AZUREML_MODEL_DIR is an environment variable created during deployment
178+
# The path "model" is the name of the registered model's folder
179+
model_path = os.path.join(os.environ["AZUREML_MODEL_DIR"], "model")
180+
181+
model = load_model(model_path)
175182
```
176183

177184
## Next steps

0 commit comments

Comments
 (0)