diff --git a/data/scripts/COCO.sh b/data/scripts/COCO.sh index 799cb135f..95a34e146 100644 --- a/data/scripts/COCO.sh +++ b/data/scripts/COCO.sh @@ -1,6 +1,10 @@ #!/bin/bash start=`date +%s` +trainfile="train2017.zip" +valfile="val2017.zip" +annotations_trainval2014="annotations_trainval2014.zip" +annotations_trainval2017="annotations_trainval2017.zip" # handle optional download dir if [ -z "$1" ] @@ -30,10 +34,23 @@ fi # Download the image data. cd ./images -echo "Downloading MSCOCO train images ..." -curl -LO http://images.cocodataset.org/zips/train2017.zip -echo "Downloading MSCOCO val images ..." -curl -LO http://images.cocodataset.org/zips/val2017.zip +# check train2017.zip exist +if [ ! -f "$trainfile" ] + then + echo "Downloading MSCOCO train images ..." + curl -LO http://images.cocodataset.org/zips/train2017.zip + else + echo "train2017.zip exist" +fi + +# check val2017.zip exist +if [ ! -f "$valfile" ] + then + echo "Downloading MSCOCO val images ..." + curl -LO http://images.cocodataset.org/zips/val2017.zip + else + echo "val2017.zip exist" +fi cd ../ if [ ! -d annotations ] @@ -43,27 +60,49 @@ fi # Download the annotation data. cd ./annotations -echo "Downloading MSCOCO train/val annotations ..." -curl -LO http://images.cocodataset.org/annotations/annotations_trainval2014.zip -curl -LO http://images.cocodataset.org/annotations/annotations_trainval2017.zip + +if [ ! -f "$annotations_trainval2014" ] || [ ! -f "$annotations_trainval2017" ]; then + echo "Downloading MSCOCO train/val annotations ..." + + if [ ! -f "$annotations_trainval2014" ]; then + echo "$annotations_trainval2014 not exist, now downloading ..." + curl -LO http://images.cocodataset.org/annotations/annotations_trainval2014.zip + fi + + if [ ! -f "$annotations_trainval2017" ]; then + echo "$annotations_trainval2017 not exist, now downloading..." + curl -LO http://images.cocodataset.org/annotations/annotations_trainval2017.zip + fi +else + echo "annotations exist" +fi + echo "Finished downloading. Now extracting ..." # Unzip data +if ls ../images/*.jpg 1> /dev/null 2>&1; then + echo "jpg files exist, starting deletion..." + rm ../images/*.jpg +fi echo "Extracting train images ..." unzip -qqjd ../images ../images/train2017.zip echo "Extracting val images ..." unzip -qqjd ../images ../images/val2017.zip + +if ls ./annotations/*.json 1> /dev/null 2>&1; then + echo "json files exist, starting deletion..." + rm ./annotations/*.json +fi echo "Extracting annotations ..." unzip -qqd .. ./annotations_trainval2014.zip unzip -qqd .. ./annotations_trainval2017.zip -echo "Removing zip files ..." +echo "Download completed, Removing zip files ..." rm ../images/train2017.zip rm ../images/val2017.zip rm ./annotations_trainval2014.zip rm ./annotations_trainval2017.zip - end=`date +%s` runtime=$((end-start))