Skip to content

Commit

Permalink
update notebooks to specify model_type explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
HannaMao committed Apr 7, 2023
1 parent c3b8a88 commit 9e1eb9f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
20 changes: 6 additions & 14 deletions notebooks/automatic_mask_generator_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,6 @@
"To run automatic mask generation, provide a SAM model to the `SamAutomaticMaskGenerator` class. Set the path below to the SAM checkpoint. Running on CUDA and with the default model is recommended."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "17ade22d",
"metadata": {},
"outputs": [],
"source": [
"sam_checkpoint = \"sam_vit_h_4b8939.pth\"\n",
"\n",
"device = \"cuda\"\n",
"model_type = \"default\""
]
},
{
"cell_type": "code",
"execution_count": 10,
Expand All @@ -238,6 +225,11 @@
"sys.path.append(\"..\")\n",
"from segment_anything import sam_model_registry, SamAutomaticMaskGenerator, SamPredictor\n",
"\n",
"sam_checkpoint = \"sam_vit_h_4b8939.pth\"\n",
"model_type = \"vit_h\"\n",
"\n",
"device = \"cuda\"\n",
"\n",
"sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)\n",
"sam.to(device=device)\n",
"\n",
Expand Down Expand Up @@ -446,7 +438,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.8.0"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/onnx_model_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"outputs": [],
"source": [
"checkpoint = \"sam_vit_h_4b8939.pth\"\n",
"model_type = \"default\""
"model_type = \"vit_h\""
]
},
{
Expand Down Expand Up @@ -766,7 +766,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.8.0"
}
},
"nbformat": 4,
Expand Down
19 changes: 6 additions & 13 deletions notebooks/predictor_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,6 @@
"First, load the SAM model and predictor. Change the path below to point to the SAM checkpoint. Running on CUDA and using the default model are recommended for best results."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "17ccff22",
"metadata": {},
"outputs": [],
"source": [
"sam_checkpoint = \"sam_vit_h_4b8939.pth\"\n",
"device = \"cuda\"\n",
"model_type = \"default\""
]
},
{
"cell_type": "code",
"execution_count": 10,
Expand All @@ -252,6 +240,11 @@
"sys.path.append(\"..\")\n",
"from segment_anything import sam_model_registry, SamPredictor\n",
"\n",
"sam_checkpoint = \"sam_vit_h_4b8939.pth\"\n",
"model_type = \"vit_h\"\n",
"\n",
"device = \"cuda\"\n",
"\n",
"sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)\n",
"sam.to(device=device)\n",
"\n",
Expand Down Expand Up @@ -1015,7 +1008,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.8.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 9e1eb9f

Please sign in to comment.