get_coco.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # Ultralytics YOLO 🚀, AGPL-3.0 license
  3. # Download COCO 2017 dataset http://cocodataset.org
  4. # Example usage: bash data/scripts/get_coco.sh
  5. # parent
  6. # ├── ultralytics
  7. # └── datasets
  8. # └── coco ← downloads here
  9. # Arguments (optional) Usage: bash data/scripts/get_coco.sh --train --val --test --segments
  10. if [ "$#" -gt 0 ]; then
  11. for opt in "$@"; do
  12. case "${opt}" in
  13. --train) train=true ;;
  14. --val) val=true ;;
  15. --test) test=true ;;
  16. --segments) segments=true ;;
  17. --sama) sama=true ;;
  18. esac
  19. done
  20. else
  21. train=true
  22. val=true
  23. test=false
  24. segments=false
  25. sama=false
  26. fi
  27. # Download/unzip labels
  28. d='../datasets' # unzip directory
  29. url=https://github.com/ultralytics/yolov5/releases/download/v1.0/
  30. if [ "$segments" == "true" ]; then
  31. f='coco2017labels-segments.zip' # 169 MB
  32. elif [ "$sama" == "true" ]; then
  33. f='coco2017labels-segments-sama.zip' # 199 MB https://www.sama.com/sama-coco-dataset/
  34. else
  35. f='coco2017labels.zip' # 46 MB
  36. fi
  37. echo 'Downloading' $url$f ' ...'
  38. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  39. # Download/unzip images
  40. d='../datasets/coco/images' # unzip directory
  41. url=http://images.cocodataset.org/zips/
  42. if [ "$train" == "true" ]; then
  43. f='train2017.zip' # 19G, 118k images
  44. echo 'Downloading' $url$f '...'
  45. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  46. fi
  47. if [ "$val" == "true" ]; then
  48. f='val2017.zip' # 1G, 5k images
  49. echo 'Downloading' $url$f '...'
  50. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  51. fi
  52. if [ "$test" == "true" ]; then
  53. f='test2017.zip' # 7G, 41k images (optional)
  54. echo 'Downloading' $url$f '...'
  55. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  56. fi
  57. wait # finish background tasks