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: README.md
+29-23Lines changed: 29 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -2,33 +2,29 @@
2
2
3
3
## Step 0: Setup RedisAI
4
4
5
-
To use RedisAI, well, you need RedisAI. I've found the easiest way to do this is with Docker. First, pull the redismod image—it contians Redis with several popular modules ready to go:
5
+
To use RedisAI, well, you need RedisAI. I've found the easiest way to do this is with Docker. First, pull the redismod image—it contains Redis with several popular modules ready to go:
6
6
7
7
$ docker image pull redislabs/redismod
8
8
9
9
Then run the image:
10
10
11
-
$ docker run \
12
-
-p 6379:6379 \
13
-
redislabs/redismod \
14
-
--loadmodule /usr/lib/redis/modules/redisai.so \
15
-
ONNX redisai_onnxruntime/redisai_onnxruntime.so
11
+
$ docker run -p 6379:6379 --name redismod redislabs/redismod
16
12
17
13
And, you've got RedisAI up and running!
18
14
19
15
## Step 1: Setup Python Environment
20
16
21
-
You need a Python environment to make this all work. I used Python 3.8—the latest, greatest, and most updatest at the time of this writing. I also used `venv` to manage my environment.
17
+
You need a Python environment to make this all work. I used Python 3.9—the latest, greatest, and most updatest at the time of this writing. I also used `venv` to manage my environment.
22
18
23
-
I'll assume you can download and install Python 3.8 on your own. So lets go ahead and setup the environment:
19
+
I'll assume you can download and install Python 3.9 on your own. So lets go ahead and setup the environment:
24
20
25
-
$ python3.8 -m venv venv
21
+
$ python3.9 -m venv .venv
26
22
27
23
Once `venv` is installed, you need to activate it:
28
24
29
-
$ . venv/bin/activate
25
+
$ . ./.venv/bin/activate
30
26
31
-
Now when you run `python` from the command line, it will always point to Python3.8 and any libraries you install will only be for this specific environment. Usually, this includes a dated version of pip so go ahead an update that as well:
27
+
Now when you run `python` from the command line, it will always point to Python3.9 and any libraries you install will only be for this specific environment. Usually, this includes a dated version of pip so go ahead an update that as well:
32
28
33
29
$ pip install --upgrade pip
34
30
@@ -45,17 +41,18 @@ Next, let's install all the dependencies. These are all listed in `requirements.
45
41
46
42
Run that command, and you'll have all the dependencies installed and will be ready to run the code.
47
43
48
-
## Step 3: Build the ONNX Model
44
+
## Step 3: Build the TorchScript Model
49
45
50
-
This is as easy as running the following:
46
+
Load and train a Sklearn LogisticRegression model using the Iris Data Set. Use Microsoft's Hummingbird.ml to convert the Sklearn model into a TorchScript model for loading into RedisAI. Run the `build.py` Python script to generate the `iris.pt` model file:
51
47
52
48
$ python build.py
53
49
54
50
## Step 4: Deploy the Model into RedisAI
55
51
56
52
NOTE: This requires redis-cli. If you don't have redis-cli, I've found the easiest way to get it is to download, build, and install Redis itself. Details can be found at the [Redis quickstart](https://redis.io/topics/quickstart) page:
57
53
58
-
$ redis-cli -x AI.MODELSET iris ONNX CPU BLOB < iris.onnx
54
+
$ redis-cli -x AI.MODELSTORE iris TORCH CPU BLOB < iris.pt
55
+
OK
59
56
60
57
## Step 5: Make Some Predictions
61
58
@@ -67,21 +64,30 @@ Set the input tensor with 2 sets of inputs of 4 values each:
What? The output tensor for the scores is required to run the model, but nothing is written to it. I'm still trying to track down this bug. `¯\_(ツ)_/¯`
0 commit comments