Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pytorch] Update load model jupyter notebook #1002

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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