""" Download public-domain example images for all four demo apps. Run once before first launch: python scripts/fetch_examples.py """ import urllib.request from pathlib import Path EXAMPLES_DIR = Path(__file__).parent.parent / "examples" EXAMPLES_DIR.mkdir(exist_ok=True) # Each entry: (local_filename, url, description) IMAGES = [ # allergen_lens — food labels ( "allergen_label.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/Nutrition_facts_label_example.jpg/640px-Nutrition_facts_label_example.jpg", "Nutrition facts label (allergen_lens example 1)", ), ( "allergen_label2.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Nutritional_labels.jpg/640px-Nutritional_labels.jpg", "Ingredient list label (allergen_lens example 2)", ), # camera_roll_concierge — varied everyday photos ( "concierge_receipt.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/Store_receipt.jpg/640px-Store_receipt.jpg", "Receipt photo (camera_roll example)", ), ( "concierge_recipe.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat_03.jpg/640px-Cat_03.jpg", "Placeholder photo (camera_roll example)", ), # object_oracle — interesting objects ( "oracle_object.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png", "Interesting object (oracle example)", ), # whats_that_error — error screens ( "error_screen.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Windows_9X_BSOD.png/640px-Windows_9X_BSOD.png", "BSOD error screen (whats_that_error example 1)", ), ( "error_screen2.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Windows_XP_BSOD.png/640px-Windows_XP_BSOD.png", "XP BSOD error screen (whats_that_error example 2)", ), ] def fetch_all(): for filename, url, desc in IMAGES: dest = EXAMPLES_DIR / filename if dest.exists(): print(f" skip {filename}") continue print(f" get {filename} — {desc}") try: urllib.request.urlretrieve(url, dest) print(f" ok {filename}") except Exception as exc: print(f" FAIL {filename}: {exc}") if __name__ == "__main__": print(f"Downloading examples to {EXAMPLES_DIR} ...") fetch_all() print("Done.")