Skip to content

Commit

Permalink
[pytorch] Update load model jupyter notebook (deepjavalibrary#1002)
Browse files Browse the repository at this point in the history
Change-Id: I1889aa93d2002e6ce02c740d2d1d3517bf586760
  • Loading branch information
frankfliu authored Jun 9, 2021
1 parent 8286930 commit b0fe73a
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions jupyter/load_pytorch_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,15 @@
"metadata": {},
"outputs": [],
"source": [
"Pipeline pipeline = new Pipeline();\n",
"pipeline.add(new Resize(256))\n",
" .add(new CenterCrop(224, 224))\n",
" .add(new ToTensor())\n",
" .add(new Normalize(\n",
" new float[] {0.485f, 0.456f, 0.406f},\n",
" new float[] {0.229f, 0.224f, 0.225f}));\n",
"\n",
"Translator<Image, Classifications> translator = ImageClassificationTranslator.builder()\n",
" .setPipeline(pipeline)\n",
" .optApplySoftmax(true)\n",
" .build();"
" .addTransform(new Resize(256))\n",
" .addTransform(new CenterCrop(224, 224))\n",
" .addTransform(new ToTensor())\n",
" .addTransform(new Normalize(\n",
" new float[] {0.485f, 0.456f, 0.406f},\n",
" new float[] {0.229f, 0.224f, 0.225f}))\n",
" .optApplySoftmax(true)\n",
" .build();"
]
},
{
Expand All @@ -141,9 +138,7 @@
"source": [
"## Step 3: Load your model\n",
"\n",
"Next, we will set the model zoo location to the `build/pytorch_models` directory we saved the model to. You can also create your own [`Repository`](https://javadoc.io/static/ai.djl/repository/0.11.0/index.html?ai/djl/repository/Repository.html) to avoid manually managing files.\n",
"\n",
"Next, we add some search criteria to find the resnet18 model and load it."
"Next, we add some search criteria to find the resnet18 model and load it. In this case, we need to tell `Criteria` where to locate the model by calling `.optModelPath()` API."
]
},
{
Expand Down Expand Up @@ -226,7 +221,7 @@
"mimetype": "text/x-java-source",
"name": "Java",
"pygments_lexer": "java",
"version": "11.0.11+9-LTS"
"version": "14.0.2+12"
},
"pycharm": {
"stem_cell": {
Expand Down

0 comments on commit b0fe73a

Please sign in to comment.