A Go implementation of Facebook's PDQ
trust-and-safety pdq
at main 46 lines 1.2 kB view raw
1#!/usr/bin/env python3 2 3import os 4import sys 5import urllib.request 6from pathlib import Path 7import time 8 9TESTDATA_DIR = "testdata/images" 10 11 12def download_images(num_images=50): 13 """Download test images of various sizes""" 14 15 Path(TESTDATA_DIR).mkdir(parents=True, exist_ok=True) 16 17 print(f"Downloading {num_images} images from Lorem Picsum...") 18 print() 19 20 for i in range(1, num_images + 1): 21 if i % 3 == 0: 22 width, height = 400, 300 23 elif i % 3 == 1: 24 width, height = 800, 600 25 else: 26 width, height = 1920, 1080 27 28 url = f"https://picsum.photos/{width}/{height}?random={i}" 29 output_path = os.path.join(TESTDATA_DIR, f"test_image_{i}.jpg") 30 31 try: 32 print(f"Downloading image {i}/{num_images} ({width}x{height})...", end=" ") 33 urllib.request.urlretrieve(url, output_path) 34 time.sleep(0.1) 35 36 except Exception as e: 37 print(f"Failed to download image: {e}") 38 39 print() 40 print("Setup complete!") 41 print(f"Downloaded images to: {TESTDATA_DIR}") 42 43 44if __name__ == "__main__": 45 num_images = int(sys.argv[1]) if len(sys.argv) > 1 else 50 46 download_images(num_images)