download_ckpts.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # Copyright (c) Meta Platforms, Inc. and affiliates.
  3. # All rights reserved.
  4. # This source code is licensed under the license found in the
  5. # LICENSE file in the root directory of this source tree.
  6. # Use either wget or curl to download the checkpoints
  7. if command -v wget &> /dev/null; then
  8. CMD="wget"
  9. elif command -v curl &> /dev/null; then
  10. CMD="curl -L -O"
  11. else
  12. echo "Please install wget or curl to download the checkpoints."
  13. exit 1
  14. fi
  15. # Define the URLs for SAM 2 checkpoints
  16. # SAM2_BASE_URL="https://dl.fbaipublicfiles.com/segment_anything_2/072824"
  17. # sam2_hiera_t_url="${SAM2_BASE_URL}/sam2_hiera_tiny.pt"
  18. # sam2_hiera_s_url="${SAM2_BASE_URL}/sam2_hiera_small.pt"
  19. # sam2_hiera_b_plus_url="${SAM2_BASE_URL}/sam2_hiera_base_plus.pt"
  20. # sam2_hiera_l_url="${SAM2_BASE_URL}/sam2_hiera_large.pt"
  21. # Download each of the four checkpoints using wget
  22. # echo "Downloading sam2_hiera_tiny.pt checkpoint..."
  23. # $CMD $sam2_hiera_t_url || { echo "Failed to download checkpoint from $sam2_hiera_t_url"; exit 1; }
  24. # echo "Downloading sam2_hiera_small.pt checkpoint..."
  25. # $CMD $sam2_hiera_s_url || { echo "Failed to download checkpoint from $sam2_hiera_s_url"; exit 1; }
  26. # echo "Downloading sam2_hiera_base_plus.pt checkpoint..."
  27. # $CMD $sam2_hiera_b_plus_url || { echo "Failed to download checkpoint from $sam2_hiera_b_plus_url"; exit 1; }
  28. # echo "Downloading sam2_hiera_large.pt checkpoint..."
  29. # $CMD $sam2_hiera_l_url || { echo "Failed to download checkpoint from $sam2_hiera_l_url"; exit 1; }
  30. # Define the URLs for SAM 2.1 checkpoints
  31. SAM2p1_BASE_URL="https://dl.fbaipublicfiles.com/segment_anything_2/092824"
  32. sam2p1_hiera_t_url="${SAM2p1_BASE_URL}/sam2.1_hiera_tiny.pt"
  33. sam2p1_hiera_s_url="${SAM2p1_BASE_URL}/sam2.1_hiera_small.pt"
  34. sam2p1_hiera_b_plus_url="${SAM2p1_BASE_URL}/sam2.1_hiera_base_plus.pt"
  35. sam2p1_hiera_l_url="${SAM2p1_BASE_URL}/sam2.1_hiera_large.pt"
  36. # SAM 2.1 checkpoints
  37. echo "Downloading sam2.1_hiera_tiny.pt checkpoint..."
  38. $CMD $sam2p1_hiera_t_url || { echo "Failed to download checkpoint from $sam2p1_hiera_t_url"; exit 1; }
  39. echo "Downloading sam2.1_hiera_small.pt checkpoint..."
  40. $CMD $sam2p1_hiera_s_url || { echo "Failed to download checkpoint from $sam2p1_hiera_s_url"; exit 1; }
  41. echo "Downloading sam2.1_hiera_base_plus.pt checkpoint..."
  42. $CMD $sam2p1_hiera_b_plus_url || { echo "Failed to download checkpoint from $sam2p1_hiera_b_plus_url"; exit 1; }
  43. echo "Downloading sam2.1_hiera_large.pt checkpoint..."
  44. $CMD $sam2p1_hiera_l_url || { echo "Failed to download checkpoint from $sam2p1_hiera_l_url"; exit 1; }
  45. echo "All checkpoints are downloaded successfully."