Skip to content

Use HTTPS for downloads in download_and_preprocess_coco.sh - #3549

Merged
aman2930 merged 1 commit into
tensorflow:masterfrom
aman2930:amangu/coco-script-https
Nov 24, 2026
Merged

aman2930 merged 1 commit into
tensorflow:masterfrom
aman2930:amangu/coco-script-https

Conversation

@aman2930

Copy link
Copy Markdown
Member

Motivation

tools/datasets/download_and_preprocess_coco.sh downloads code and data over plain HTTP:

  • It clones tensorflow/models from http://github.com/... and then runs Python code from that clone (PYTHONPATH=tf-models:tf-models/research).
  • It downloads the COCO annotation and image archives (about 25 GB) from http://images.cocodataset.org/... and unzips them.

Plain HTTP is not encrypted or authenticated, so anyone on the network path could change these files while they are downloaded. This PR switches every download in the script to HTTPS.

Modifications

tools/datasets/download_and_preprocess_coco.sh:

  • Clone tensorflow/models from https://github.com/tensorflow/models.
  • Download COCO files from https://s3.amazonaws.com/images.cocodataset.org/... instead of http://images.cocodataset.org/... (6 URLs: the annotations base URL and the 4 image base URLs, used by 7 downloads in total).
    • Why not just https://images.cocodataset.org? That host name serves the images.cocodataset.org S3 bucket, but it has no matching TLS certificate, so wget fails over HTTPS ("no alternative certificate subject name matches"). The S3 path-style URL serves the same bucket over HTTPS with a valid certificate. A short comment in the script explains this.
  • Use https://cocodataset.org/#overview for the link in the header comment.

No other behavior changes: same files, same output directories, same TFRecord conversion.

Tests

The full script needs sudo apt, about 50 GB of disk and hours of conversion, so I checked each changed part on its own:

Check Result
bash -n syntax check pass
All 7 files (annotations_trainval2017, image_info_test2017, image_info_unlabeled2017, train2017, val2017, test2017, unlabeled2017) over the new HTTPS URL HTTP 200, TLS certificate valid
Same file as before? Compared Content-Length and ETag of the old HTTP URL and the new HTTPS URL for all 7 files identical for all 7
Old host over HTTPS (https://images.cocodataset.org/...) fails TLS validation (why we use the S3 path-style URL)
wget --spider on a new URL (the script uses wget) pass
wget -nd -c + unzip -nq of image_info_test2017.zip (same commands the script uses) pass; image_info_test2017.json and image_info_test-dev2017.json extracted
git clone https://github.com/tensorflow/models pass; research/object_detection/protos present

Accuracy / speed tests

Not applicable. This only changes where the script downloads from. The downloaded files are byte-for-byte the same (same size and ETag), so the generated TFRecords don't change.

Possible follow-ups (not in this PR)

  • Pin tensorflow/models to a fixed commit, so a future upstream change can't break or alter the conversion step.
  • Check a recorded SHA-256 for each archive before unzipping.

The COCO preparation script fetched the tensorflow/models repository and
the COCO zip archives over plain HTTP. The script then runs Python code
from the cloned repository and unzips the archives. Someone on the
network path could change these files while they are downloaded.

Changes:
- Clone tensorflow/models over https://github.com.
- Download COCO annotations and images from
  https://s3.amazonaws.com/images.cocodataset.org. The host name
  images.cocodataset.org only serves plain HTTP (its TLS certificate does
  not match), so the script uses the S3 path-style HTTPS URL for the same
  bucket. The files are the same (same size and ETag).
- Use https for the cocodataset.org link in the header comment.
@aman2930
aman2930 merged commit 7d2527a into tensorflow:master Nov 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant