a b/data/scripts/get_coco.sh
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
10
# Arguments (optional) Usage: bash data/scripts/get_coco.sh --train --val --test --segments
11
if [ "$#" -gt 0 ]; then
12
  for opt in "$@"; do
13
    case "${opt}" in
14
    --train) train=true ;;
15
    --val) val=true ;;
16
    --test) test=true ;;
17
    --segments) segments=true ;;
18
    esac
19
  done
20
else
21
  train=true
22
  val=true
23
  test=false
24
  segments=false
25
fi
26
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' # 168 MB
32
else
33
  f='coco2017labels.zip' # 46 MB
34
fi
35
echo 'Downloading' $url$f ' ...'
36
curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
37
38
# Download/unzip images
39
d='../datasets/coco/images' # unzip directory
40
url=http://images.cocodataset.org/zips/
41
if [ "$train" == "true" ]; then
42
  f='train2017.zip' # 19G, 118k images
43
  echo 'Downloading' $url$f '...'
44
  curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
45
fi
46
if [ "$val" == "true" ]; then
47
  f='val2017.zip' # 1G, 5k images
48
  echo 'Downloading' $url$f '...'
49
  curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
50
fi
51
if [ "$test" == "true" ]; then
52
  f='test2017.zip' # 7G, 41k images (optional)
53
  echo 'Downloading' $url$f '...'
54
  curl -L $url$f -o $f -# && unzip -q $f -d $d && rm $f &
55
fi
56
wait # finish background tasks