# SPDX-FileCopyrightText: © 2026 Tenstorrent AI ULC # SPDX-License-Identifier: Apache-2.0 """README quickstart on the repo's demo input. Writes quickstart_out.png and quickstart_out.json. pip install -e code/ # once, in the tt-metal Python environment python examples/quickstart.py [image] [query] The default image is found relative to this file (media/demo_input.png in the repo), so you can start the script from any directory. A relative [image] path is relative to the current directory. The outputs go to the current directory. """ import json import os import sys from locate_anything import LocateAnything here = os.path.dirname(os.path.abspath(__file__)) image = sys.argv[1] if len(sys.argv) > 1 else os.path.join(here, "..", "media", "demo_input.png") query = sys.argv[2] if len(sys.argv) > 2 else "car" # --- the README snippet --------------------------------------------------------------- with LocateAnything.from_pretrained(device_id=0) as model: # downloads weights, opens the chip, warms up # the warm-up (warmup_variants="default") makes this first call as fast as later calls result = model(image, query) # path, PIL image, numpy or torch array for label, box in zip(result.labels, result.boxes): print(label, box.round(1)) # x1 y1 x2 y2 in image pixels result.draw().save("quickstart_out.png") # --------------------------------------------------------------------------------------- with open("quickstart_out.json", "w") as f: json.dump(result.to_dict(), f, indent=1) print(f"raw_text={result.raw_text!r} model time {result.timing_ms['total']} ms") print("wrote quickstart_out.png, quickstart_out.json")