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/azure-functions/machine-learning-pytorch.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Deploy a PyTorch model as an Azure Functions application
3
-
description: Use Python, PyTorch, and Azure Functions to classify an image
3
+
description: Use a pre-trained ResNet 18 deep neural network from PyTorch with Azure Functions to assign 1 of 1000 ImageNet labels to an image.
4
4
author: gvashishtha
5
5
6
6
ms.topic: tutorial
@@ -149,7 +149,7 @@ In Azure Functions, a function project is a container for one or more individual
149
149
150
150
To modify the `classify` function to classify an image based on its contents, you use a pre-trained [ResNet](https://arxiv.org/abs/1512.03385) model. The pre-trained model, which comes from [PyTorch](https://pytorch.org/hub/pytorch_vision_resnet/), classifies an image into 1 of 1000 [ImageNet classes](https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a). You then add some helper code and dependencies to your project.
151
151
152
-
1. In the *start* folder, run following command to copy the prediction code and labels into the *classify* folder.
152
+
1. In the *start* folder, run the following command to copy the prediction code and labels into the *classify* folder.
153
153
154
154
# [bash](#tab/bash)
155
155
@@ -176,7 +176,7 @@ To modify the `classify` function to classify an image based on its contents, yo
176
176
177
177
1. Verify that the *classify* folder contains files named *predict.py* and *labels.txt*. If not, check that you ran the command in the *start* folder.
178
178
179
-
1. Open *start/requirements.txt* in a text editor and add the following dependencies required by the helper code:
179
+
1. Open *start/requirements.txt* in a text editor and add the dependencies required by the helper code, which should look like the following:
180
180
181
181
```txt
182
182
azure-functions
@@ -191,14 +191,16 @@ To modify the `classify` function to classify an image based on its contents, yo
191
191
torchvision==0.5.0
192
192
```
193
193
194
-
1. Save *requirements.txt*.
194
+
1. Save *requirements.txt*, then run the following command from the *start* folder to install the dependencies.
195
195
196
-
1. Install the dependencies by running the following command in the *start* folder. Installation may take a few minutes, during which time you can proceed with modifying the function in the next section.
197
196
198
197
```
199
198
pip install --no-cache-dir -r requirements.txt
200
199
```
201
200
201
+
Installation may take a few minutes, during which time you can proceed with modifying the function in the next section.
202
+
203
+
202
204
On Windows, you may encounter the error, "Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory:" followed by a long pathname to a file like *sharded_mutable_dense_hashtable.cpython-37.pyc*. Typically, this error happens because the depth of the folder path becomes too long. In this case, set the registry key `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled` to `1` to enable long paths. Alternately, check where your Python interpreter is installed. If that location has a long path, try reinstalling in a folder with a shorter path.
203
205
204
206
## Update the function to run predictions
@@ -268,7 +270,7 @@ To test invoking the function endpoint from another web app, there's a simple ap
268
270
269
271
1. Select **Submit** to invoke the function endpoint to classify the image.
270
272
271
-

273
+

272
274
273
275
If the browser reports an error when you submit the image URL, check the terminal in which you're running the function app. If you see an error like "No module found 'PIL'", you may have started the function app in the *start* folder without first activating the virtual environment you created earlier. If you still see errors, run `pip install -r requirements.txt` again with the virtual environment activated and look for errors.
0 commit comments