From 87e15c79634ed0eaaa65baaed7f4f8441b8fefb1 Mon Sep 17 00:00:00 2001 From: Carlos Menezes Date: Tue, 30 Jul 2024 22:56:39 +0100 Subject: [PATCH] feat: add checkpoint download script for Windows --- README.md | 3 ++- checkpoints/download_ckpts.ps1 | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 checkpoints/download_ckpts.ps1 diff --git a/README.md b/README.md index dd8c8862..8ca269d8 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/checkpoints/download_ckpts.ps1 b/checkpoints/download_ckpts.ps1 new file mode 100644 index 00000000..d5af81dc --- /dev/null +++ b/checkpoints/download_ckpts.ps1 @@ -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."