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

feat: add checkpoint download script for Windows #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ First, we need to download a model checkpoint. All the model checkpoints can be

```bash
cd checkpoints
./download_ckpts.sh
./download_ckpts.sh # on Unix
./download_ckpts.ps1 # on Windows
```

or individually from:
Expand Down
43 changes: 43 additions & 0 deletions checkpoints/download_ckpts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.

# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

# Define the URLs for the checkpoints
$baseUrl = "https://dl.fbaipublicfiles.com/segment_anything_2/072824/"
$sam2_hiera_t_url = "${baseUrl}sam2_hiera_tiny.pt"
$sam2_hiera_s_url = "${baseUrl}sam2_hiera_small.pt"
$sam2_hiera_b_plus_url = "${baseUrl}sam2_hiera_base_plus.pt"
$sam2_hiera_l_url = "${baseUrl}sam2_hiera_large.pt"

# Function to download files
function Get-File {
param (
[string]$url,
[string]$filename
)
try {
Invoke-WebRequest -Uri $url -OutFile $filename
Write-Host "$filename downloaded successfully."
}
catch {
Write-Host "Failed to download checkpoint from $url"
exit 1
}
}

# Download each of the four checkpoints
Write-Host "Downloading sam2_hiera_tiny.pt checkpoint..."
Download-File -url $sam2_hiera_t_url -filename "sam2_hiera_tiny.pt"

Write-Host "Downloading sam2_hiera_small.pt checkpoint..."
Download-File -url $sam2_hiera_s_url -filename "sam2_hiera_small.pt"

Write-Host "Downloading sam2_hiera_base_plus.pt checkpoint..."
Download-File -url $sam2_hiera_b_plus_url -filename "sam2_hiera_base_plus.pt"

Write-Host "Downloading sam2_hiera_large.pt checkpoint..."
Download-File -url $sam2_hiera_l_url -filename "sam2_hiera_large.pt"

Write-Host "All checkpoints are downloaded successfully."