# --------------------------------------------------------------------- # Copyright (c) 2026 Qualcomm Technologies, Inc. and/or its subsidiaries. # SPDX-License-Identifier: BSD-3-Clause # --------------------------------------------------------------------- from __future__ import annotations from qai_hub_models.utils.args import ( demo_model_from_cli_args, get_model_cli_parser, get_on_device_demo_parser, validate_on_device_demo_args, ) from qai_hub_models.utils.asset_loaders import CachedWebModelAsset, load_image from qai_hub_models.utils.display import display_or_save_image from .app import DepthProApp from .model import MODEL_ID, DepthPro # Reuse the midas depth-estimation fixture — any indoor/outdoor natural image # works; keeping this out-of-tree avoids uploading a fresh asset just for # the initial recipe. INPUT_IMAGE_ADDRESS = CachedWebModelAsset.from_asset_store( "midas", 3, "test_input_image.jpg" ) def main(is_test: bool = False) -> None: parser = get_model_cli_parser(DepthPro) parser = get_on_device_demo_parser(parser, add_output_dir=True) parser.add_argument( "--image", type=str, default=INPUT_IMAGE_ADDRESS, help="image file path or URL", ) args = parser.parse_args([] if is_test else None) model = demo_model_from_cli_args(DepthPro, MODEL_ID, args) validate_on_device_demo_args(args, MODEL_ID) (_, _, height, width) = model.get_input_spec()["image"][0] image = load_image(args.image) print("Model Loaded") app = DepthProApp(model, height, width) # type: ignore[arg-type] prediction = app.estimate_depth(image) print( f"Predicted field of view: {prediction.field_of_view:.2f} deg " f"(focal length: {prediction.focal_length_px:.1f} px)" ) if not is_test: display_or_save_image( prediction.heatmap, args.output_dir, "out_heatmap.png", "heatmap" ) if __name__ == "__main__": main()