get_coco.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # YOLOv5 🚀 by Ultralytics, AGPL-3.0 license
  3. # Download COCO 2017 dataset http://cocodataset.org
  4. # Example usage: bash data/scripts/get_coco.sh
  5. # parent
  6. # ├── yolov5
  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. esac
  18. done
  19. else
  20. train=true
  21. val=true
  22. test=false
  23. segments=false
  24. fi
  25. # Download/unzip labels
  26. d='../datasets' # unzip directory
  27. url=https://github.com/ultralytics/yolov5/releases/download/v1.0/
  28. if [ "$segments" == "true" ]; then
  29. f='coco2017labels-segments.zip' # 168 MB
  30. else
  31. f='coco2017labels.zip' # 46 MB
  32. fi
  33. echo 'Downloading' $url$f ' ...'
  34. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  35. # Download/unzip images
  36. d='../datasets/coco/images' # unzip directory
  37. url=http://images.cocodataset.org/zips/
  38. if [ "$train" == "true" ]; then
  39. f='train2017.zip' # 19G, 118k images
  40. echo 'Downloading' $url$f '...'
  41. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  42. fi
  43. if [ "$val" == "true" ]; then
  44. f='val2017.zip' # 1G, 5k images
  45. echo 'Downloading' $url$f '...'
  46. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  47. fi
  48. if [ "$test" == "true" ]; then
  49. f='test2017.zip' # 7G, 41k images (optional)
  50. echo 'Downloading' $url$f '...'
  51. curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
  52. fi
  53. wait # finish background tasks