From 03ff7b80711250d54f938c1131b1111e687e3238 Mon Sep 17 00:00:00 2001 From: Qualcomm AI Stack Models Bot Date: Fri, 23 Feb 2024 14:26:44 -0800 Subject: [PATCH] v0.3.1 Signed-off-by: Kory Watson --- README.md | 107 +++++++++--------- mypy.ini | 6 + qai_hub_models/_version.py | 2 +- qai_hub_models/datasets/imagenette.py | 13 ++- .../_shared/cityscapes_segmentation/demo.py | 8 +- qai_hub_models/models/_shared/deeplab/demo.py | 35 ++++-- .../models/_shared/ffnet_quantized/model.py | 9 +- .../_shared/imagenet_classifier/model.py | 10 +- .../models/baichuan_7b_quantized/README.md | 10 +- .../models/controlnet_quantized/README.md | 10 +- .../models/controlnet_quantized/demo.py | 45 ++++++-- .../models/controlnet_quantized/export.py | 33 ++++-- .../models/controlnet_quantized/perf.yaml | 8 +- qai_hub_models/models/convnext_tiny/README.md | 10 +- qai_hub_models/models/convnext_tiny/export.py | 7 +- qai_hub_models/models/ddrnet23_slim/README.md | 10 +- qai_hub_models/models/ddrnet23_slim/demo.py | 4 +- qai_hub_models/models/ddrnet23_slim/export.py | 7 +- .../models/deeplabv3_resnet50/README.md | 10 +- .../models/deeplabv3_resnet50/export.py | 7 +- .../models/deeplabv3_resnet50/model.py | 2 +- qai_hub_models/models/densenet121/README.md | 10 +- qai_hub_models/models/densenet121/export.py | 7 +- .../models/detr_resnet101/README.md | 10 +- .../models/detr_resnet101/export.py | 7 +- .../models/detr_resnet101_dc5/README.md | 10 +- .../models/detr_resnet101_dc5/export.py | 7 +- qai_hub_models/models/detr_resnet50/README.md | 10 +- qai_hub_models/models/detr_resnet50/export.py | 7 +- .../models/detr_resnet50_dc5/README.md | 10 +- .../models/detr_resnet50_dc5/export.py | 7 +- .../models/efficientnet_b0/README.md | 10 +- .../models/efficientnet_b0/export.py | 7 +- qai_hub_models/models/esrgan/README.md | 10 +- qai_hub_models/models/esrgan/export.py | 7 +- .../models/facebook_denoiser/README.md | 10 +- .../models/facebook_denoiser/export.py | 7 +- qai_hub_models/models/fastsam_s/README.md | 10 +- qai_hub_models/models/fastsam_s/export.py | 7 +- qai_hub_models/models/fastsam_x/README.md | 10 +- qai_hub_models/models/fastsam_x/export.py | 7 +- qai_hub_models/models/fcn_resnet50/README.md | 10 +- qai_hub_models/models/fcn_resnet50/demo.py | 4 +- qai_hub_models/models/fcn_resnet50/export.py | 7 +- .../models/ffnet_122ns_lowres/README.md | 10 +- .../models/ffnet_122ns_lowres/export.py | 7 +- qai_hub_models/models/ffnet_40s/README.md | 10 +- qai_hub_models/models/ffnet_40s/export.py | 7 +- .../models/ffnet_40s_quantized/README.md | 10 +- .../models/ffnet_40s_quantized/export.py | 8 +- qai_hub_models/models/ffnet_54s/README.md | 10 +- qai_hub_models/models/ffnet_54s/export.py | 7 +- .../models/ffnet_54s_quantized/README.md | 10 +- .../models/ffnet_54s_quantized/export.py | 8 +- qai_hub_models/models/ffnet_78s/README.md | 10 +- qai_hub_models/models/ffnet_78s/export.py | 7 +- .../models/ffnet_78s_lowres/README.md | 10 +- .../models/ffnet_78s_lowres/export.py | 7 +- .../models/ffnet_78s_quantized/README.md | 10 +- .../models/ffnet_78s_quantized/export.py | 8 +- qai_hub_models/models/googlenet/README.md | 10 +- qai_hub_models/models/googlenet/export.py | 7 +- .../models/googlenet_quantized/README.md | 10 +- .../models/googlenet_quantized/export.py | 12 +- qai_hub_models/models/hrnet_pose/README.md | 10 +- qai_hub_models/models/hrnet_pose/export.py | 7 +- .../models/hrnet_pose_quantized/README.md | 10 +- .../models/hrnet_pose_quantized/export.py | 8 +- .../models/hrnet_pose_quantized/model.py | 14 ++- .../huggingface_wavlm_base_plus/README.md | 10 +- .../huggingface_wavlm_base_plus/export.py | 7 +- qai_hub_models/models/inception_v3/README.md | 10 +- qai_hub_models/models/inception_v3/export.py | 7 +- .../models/inception_v3_quantized/README.md | 10 +- .../models/inception_v3_quantized/export.py | 12 +- .../models/inception_v3_quantized/model.py | 5 +- .../models/inception_v3_quantized/perf.yaml | 16 +-- qai_hub_models/models/lama_dilated/README.md | 10 +- qai_hub_models/models/lama_dilated/export.py | 7 +- qai_hub_models/models/litehrnet/README.md | 10 +- qai_hub_models/models/litehrnet/export.py | 7 +- .../llama_v2_7b_chat_quantized/README.md | 31 +++++ .../llama_v2_7b_chat_quantized/info.yaml | 46 ++++++++ .../llama_v2_7b_chat_quantized/perf.yaml | 77 +++++++++++++ .../models/mediapipe_face/README.md | 10 +- .../models/mediapipe_face/export.py | 12 +- .../models/mediapipe_hand/README.md | 10 +- .../models/mediapipe_hand/export.py | 12 +- .../models/mediapipe_pose/README.md | 10 +- .../models/mediapipe_pose/export.py | 12 +- .../models/mediapipe_selfie/README.md | 10 +- .../models/mediapipe_selfie/export.py | 7 +- qai_hub_models/models/mnasnet05/README.md | 10 +- qai_hub_models/models/mnasnet05/export.py | 7 +- qai_hub_models/models/mobilenet_v2/README.md | 10 +- qai_hub_models/models/mobilenet_v2/export.py | 7 +- .../models/mobilenet_v2_quantized/README.md | 10 +- .../models/mobilenet_v2_quantized/export.py | 14 +-- .../models/mobilenet_v2_quantized/model.py | 15 +-- .../models/mobilenet_v3_large/README.md | 10 +- .../models/mobilenet_v3_large/export.py | 7 +- .../models/mobilenet_v3_small/README.md | 10 +- .../models/mobilenet_v3_small/export.py | 7 +- qai_hub_models/models/openai_clip/README.md | 10 +- qai_hub_models/models/openai_clip/export.py | 12 +- qai_hub_models/models/openpose/README.md | 10 +- qai_hub_models/models/openpose/export.py | 7 +- .../models/quicksrnetlarge/README.md | 10 +- .../models/quicksrnetlarge/export.py | 7 +- .../models/quicksrnetmedium/README.md | 10 +- .../models/quicksrnetmedium/export.py | 7 +- .../models/quicksrnetsmall/README.md | 10 +- .../models/quicksrnetsmall/export.py | 10 +- .../models/real_esrgan_general_x4v3/README.md | 10 +- .../models/real_esrgan_general_x4v3/export.py | 7 +- .../models/real_esrgan_x4plus/README.md | 10 +- .../models/real_esrgan_x4plus/export.py | 7 +- qai_hub_models/models/regnet/README.md | 10 +- qai_hub_models/models/regnet/export.py | 7 +- qai_hub_models/models/resnet101/README.md | 10 +- qai_hub_models/models/resnet101/export.py | 7 +- .../models/resnet101_quantized/README.md | 10 +- .../models/resnet101_quantized/export.py | 12 +- .../models/resnet101_quantized/model.py | 5 +- qai_hub_models/models/resnet18/README.md | 10 +- qai_hub_models/models/resnet18/export.py | 7 +- .../models/resnet18_quantized/README.md | 10 +- .../models/resnet18_quantized/export.py | 14 +-- .../models/resnet18_quantized/model.py | 10 +- .../models/resnet18_quantized/perf.yaml | 36 +++--- qai_hub_models/models/resnet50/README.md | 10 +- qai_hub_models/models/resnet50/export.py | 7 +- qai_hub_models/models/resnext101/README.md | 10 +- qai_hub_models/models/resnext101/export.py | 7 +- .../models/resnext101_quantized/README.md | 10 +- .../models/resnext101_quantized/export.py | 12 +- .../models/resnext101_quantized/model.py | 5 +- qai_hub_models/models/resnext50/README.md | 10 +- qai_hub_models/models/resnext50/export.py | 7 +- qai_hub_models/models/sam/README.md | 10 +- qai_hub_models/models/sam/export.py | 12 +- qai_hub_models/models/sesr_m5/README.md | 10 +- qai_hub_models/models/sesr_m5/export.py | 7 +- .../models/sesr_m5_quantized/README.md | 10 +- .../models/sesr_m5_quantized/export.py | 8 +- .../models/sesr_m5_quantized/model.py | 14 ++- qai_hub_models/models/shufflenet_v2/README.md | 10 +- qai_hub_models/models/shufflenet_v2/export.py | 7 +- .../models/shufflenet_v2_quantized/README.md | 10 +- .../models/shufflenet_v2_quantized/export.py | 14 +-- .../models/shufflenet_v2_quantized/model.py | 5 +- qai_hub_models/models/sinet/README.md | 10 +- qai_hub_models/models/sinet/export.py | 7 +- qai_hub_models/models/squeezenet1_1/README.md | 10 +- qai_hub_models/models/squeezenet1_1/export.py | 7 +- .../models/squeezenet1_1_quantized/README.md | 10 +- .../models/squeezenet1_1_quantized/export.py | 8 +- .../stable_diffusion_quantized/README.md | 10 +- .../models/stable_diffusion_quantized/demo.py | 38 +++++-- .../stable_diffusion_quantized/export.py | 23 ++-- .../stable_diffusion_quantized/perf.yaml | 6 +- qai_hub_models/models/stylegan2/README.md | 10 +- qai_hub_models/models/stylegan2/app.py | 4 +- qai_hub_models/models/stylegan2/demo.py | 16 ++- qai_hub_models/models/stylegan2/export.py | 7 +- qai_hub_models/models/stylegan2/model.py | 2 +- qai_hub_models/models/swin_base/README.md | 10 +- qai_hub_models/models/swin_base/export.py | 7 +- qai_hub_models/models/swin_small/README.md | 10 +- qai_hub_models/models/swin_small/export.py | 7 +- qai_hub_models/models/swin_tiny/README.md | 10 +- qai_hub_models/models/swin_tiny/export.py | 7 +- qai_hub_models/models/trocr/README.md | 10 +- qai_hub_models/models/trocr/export.py | 12 +- .../models/unet_segmentation/README.md | 10 +- .../models/unet_segmentation/export.py | 7 +- qai_hub_models/models/vit/README.md | 10 +- qai_hub_models/models/vit/export.py | 7 +- qai_hub_models/models/whisper_asr/README.md | 10 +- qai_hub_models/models/whisper_asr/export.py | 21 +--- qai_hub_models/models/wideresnet50/README.md | 10 +- qai_hub_models/models/wideresnet50/export.py | 7 +- .../models/wideresnet50_quantized/README.md | 10 +- .../models/wideresnet50_quantized/export.py | 8 +- qai_hub_models/models/xlsr/README.md | 10 +- qai_hub_models/models/xlsr/export.py | 7 +- .../models/xlsr_quantized/README.md | 10 +- .../models/xlsr_quantized/export.py | 8 +- qai_hub_models/models/xlsr_quantized/model.py | 14 ++- qai_hub_models/models/yolov6/README.md | 10 +- qai_hub_models/models/yolov6/export.py | 7 +- qai_hub_models/models/yolov7/README.md | 10 +- qai_hub_models/models/yolov7/export.py | 7 +- qai_hub_models/models/yolov8_det/README.md | 10 +- qai_hub_models/models/yolov8_det/export.py | 7 +- qai_hub_models/models/yolov8_seg/README.md | 10 +- qai_hub_models/models/yolov8_seg/export.py | 7 +- qai_hub_models/requirements-dev.txt | 1 + qai_hub_models/requirements.txt | 4 +- qai_hub_models/utils/aimet/config_loader.py | 5 + .../aimet/default_config_per_channel_qnn.json | 68 +++++++++++ qai_hub_models/utils/args.py | 49 +++++--- qai_hub_models/utils/base_model.py | 3 + qai_hub_models/utils/compare.py | 72 +++++++++--- qai_hub_models/utils/config_loaders.py | 1 + qai_hub_models/utils/image_processing.py | 24 ++-- qai_hub_models/utils/inference.py | 38 +++++++ qai_hub_models/utils/printing.py | 42 ++++--- qai_hub_models/utils/quantization.py | 15 ++- qai_hub_models/utils/quantization_aimet.py | 13 +++ qai_hub_models/utils/test_compare.py | 20 ++++ 211 files changed, 1624 insertions(+), 885 deletions(-) create mode 100644 qai_hub_models/models/llama_v2_7b_chat_quantized/README.md create mode 100644 qai_hub_models/models/llama_v2_7b_chat_quantized/info.yaml create mode 100644 qai_hub_models/models/llama_v2_7b_chat_quantized/perf.yaml create mode 100644 qai_hub_models/utils/aimet/default_config_per_channel_qnn.json create mode 100644 qai_hub_models/utils/test_compare.py diff --git a/README.md b/README.md index 04135cb6..a0ea1dd6 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ pt_model = torch.jit.trace(torch_model, example_input) # Select a device device = hub.Device("Samsung Galaxy S23") -# Compile model on a specific device +# Compile model for a specific device compile_job = hub.submit_compile_job( model=pt_model, device=device, @@ -196,13 +196,13 @@ compile_job = hub.submit_compile_job( # Get target model to run on a cloud hosted device target_model = compile_job.get_target_model() -# Profile the previously compiled model +# Profile the previously compiled model on a cloud hosted device profile_job = hub.submit_profile_job( model=target_model, device=device, ) -# Perform on-device inference on the cloud hosted device +# Perform on-device inference on a cloud hosted device input_data = torch_model.sample_inputs() inference_job = hub.submit_inference_job( model=target_model, @@ -252,37 +252,37 @@ For any issues, please contact us at ai-hub-support@qti.qualcomm.com. | -- | -- | -- | -- | -- | | | | | | **Image Classification** -| [ResNet50](https://aihub.qualcomm.com/models/resnet50) | [qai_hub_models.models.resnet50](qai_hub_models/models/resnet50/README.md) | ✔️ | ✔️ | ✔️ -| [SqueezeNet-1_1Quantized](https://aihub.qualcomm.com/models/squeezenet1_1_quantized) | [qai_hub_models.models.squeezenet1_1_quantized](qai_hub_models/models/squeezenet1_1_quantized/README.md) | ✔️ | ✔️ | ✔️ -| [MNASNet05](https://aihub.qualcomm.com/models/mnasnet05) | [qai_hub_models.models.mnasnet05](qai_hub_models/models/mnasnet05/README.md) | ✔️ | ✔️ | ✔️ +| [GoogLeNet](https://aihub.qualcomm.com/models/googlenet) | [qai_hub_models.models.googlenet](qai_hub_models/models/googlenet/README.md) | ✔️ | ✔️ | ✔️ +| [EfficientNet-B0](https://aihub.qualcomm.com/models/efficientnet_b0) | [qai_hub_models.models.efficientnet_b0](qai_hub_models/models/efficientnet_b0/README.md) | ✔️ | ✔️ | ✔️ +| [Shufflenet-v2Quantized](https://aihub.qualcomm.com/models/shufflenet_v2_quantized) | [qai_hub_models.models.shufflenet_v2_quantized](qai_hub_models/models/shufflenet_v2_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [ResNet101](https://aihub.qualcomm.com/models/resnet101) | [qai_hub_models.models.resnet101](qai_hub_models/models/resnet101/README.md) | ✔️ | ✔️ | ✔️ +| [Inception-v3Quantized](https://aihub.qualcomm.com/models/inception_v3_quantized) | [qai_hub_models.models.inception_v3_quantized](qai_hub_models/models/inception_v3_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [ResNeXt101](https://aihub.qualcomm.com/models/resnext101) | [qai_hub_models.models.resnext101](qai_hub_models/models/resnext101/README.md) | ✔️ | ✔️ | ✔️ +| [ResNeXt50](https://aihub.qualcomm.com/models/resnext50) | [qai_hub_models.models.resnext50](qai_hub_models/models/resnext50/README.md) | ✔️ | ✔️ | ✔️ +| [GoogLeNetQuantized](https://aihub.qualcomm.com/models/googlenet_quantized) | [qai_hub_models.models.googlenet_quantized](qai_hub_models/models/googlenet_quantized/README.md) | ✔️ | ✔️ | ✔️ | [Swin-Small](https://aihub.qualcomm.com/models/swin_small) | [qai_hub_models.models.swin_small](qai_hub_models/models/swin_small/README.md) | ✔️ | ✔️ | ✔️ -| [Swin-Base](https://aihub.qualcomm.com/models/swin_base) | [qai_hub_models.models.swin_base](qai_hub_models/models/swin_base/README.md) | ✔️ | ✔️ | ✔️ -| [MobileNet-v3-Small](https://aihub.qualcomm.com/models/mobilenet_v3_small) | [qai_hub_models.models.mobilenet_v3_small](qai_hub_models/models/mobilenet_v3_small/README.md) | ✔️ | ✔️ | ✔️ | [RegNet](https://aihub.qualcomm.com/models/regnet) | [qai_hub_models.models.regnet](qai_hub_models/models/regnet/README.md) | ✔️ | ✔️ | ✔️ -| [GoogLeNetQuantized](https://aihub.qualcomm.com/models/googlenet_quantized) | [qai_hub_models.models.googlenet_quantized](qai_hub_models/models/googlenet_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [MobileNet-v2](https://aihub.qualcomm.com/models/mobilenet_v2) | [qai_hub_models.models.mobilenet_v2](qai_hub_models/models/mobilenet_v2/README.md) | ✔️ | ✔️ | ✔️ +| [Inception-v3](https://aihub.qualcomm.com/models/inception_v3) | [qai_hub_models.models.inception_v3](qai_hub_models/models/inception_v3/README.md) | ✔️ | ✔️ | ✔️ +| [SqueezeNet-1_1](https://aihub.qualcomm.com/models/squeezenet1_1) | [qai_hub_models.models.squeezenet1_1](qai_hub_models/models/squeezenet1_1/README.md) | ✔️ | ✔️ | ✔️ +| [ResNeXt101Quantized](https://aihub.qualcomm.com/models/resnext101_quantized) | [qai_hub_models.models.resnext101_quantized](qai_hub_models/models/resnext101_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [MobileNet-v3-Small](https://aihub.qualcomm.com/models/mobilenet_v3_small) | [qai_hub_models.models.mobilenet_v3_small](qai_hub_models/models/mobilenet_v3_small/README.md) | ✔️ | ✔️ | ✔️ +| [ResNet18Quantized](https://aihub.qualcomm.com/models/resnet18_quantized) | [qai_hub_models.models.resnet18_quantized](qai_hub_models/models/resnet18_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [Swin-Base](https://aihub.qualcomm.com/models/swin_base) | [qai_hub_models.models.swin_base](qai_hub_models/models/swin_base/README.md) | ✔️ | ✔️ | ✔️ +| [Shufflenet-v2](https://aihub.qualcomm.com/models/shufflenet_v2) | [qai_hub_models.models.shufflenet_v2](qai_hub_models/models/shufflenet_v2/README.md) | ✔️ | ✔️ | ✔️ | [WideResNet50-Quantized](https://aihub.qualcomm.com/models/wideresnet50_quantized) | [qai_hub_models.models.wideresnet50_quantized](qai_hub_models/models/wideresnet50_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [ConvNext-Tiny](https://aihub.qualcomm.com/models/convnext_tiny) | [qai_hub_models.models.convnext_tiny](qai_hub_models/models/convnext_tiny/README.md) | ✔️ | ✔️ | ✔️ +| [ResNet18](https://aihub.qualcomm.com/models/resnet18) | [qai_hub_models.models.resnet18](qai_hub_models/models/resnet18/README.md) | ✔️ | ✔️ | ✔️ +| [WideResNet50](https://aihub.qualcomm.com/models/wideresnet50) | [qai_hub_models.models.wideresnet50](qai_hub_models/models/wideresnet50/README.md) | ✔️ | ✔️ | ✔️ | [MobileNet-v3-Large](https://aihub.qualcomm.com/models/mobilenet_v3_large) | [qai_hub_models.models.mobilenet_v3_large](qai_hub_models/models/mobilenet_v3_large/README.md) | ✔️ | ✔️ | ✔️ +| [Swin-Tiny](https://aihub.qualcomm.com/models/swin_tiny) | [qai_hub_models.models.swin_tiny](qai_hub_models/models/swin_tiny/README.md) | ✔️ | ✔️ | ✔️ +| [MNASNet05](https://aihub.qualcomm.com/models/mnasnet05) | [qai_hub_models.models.mnasnet05](qai_hub_models/models/mnasnet05/README.md) | ✔️ | ✔️ | ✔️ +| [VIT](https://aihub.qualcomm.com/models/vit) | [qai_hub_models.models.vit](qai_hub_models/models/vit/README.md) | ✔️ | ✔️ | ✔️ | [MobileNet-v2-Quantized](https://aihub.qualcomm.com/models/mobilenet_v2_quantized) | [qai_hub_models.models.mobilenet_v2_quantized](qai_hub_models/models/mobilenet_v2_quantized/README.md) | ✔️ | ✔️ | ✔️ -| [ResNeXt101Quantized](https://aihub.qualcomm.com/models/resnext101_quantized) | [qai_hub_models.models.resnext101_quantized](qai_hub_models/models/resnext101_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [SqueezeNet-1_1Quantized](https://aihub.qualcomm.com/models/squeezenet1_1_quantized) | [qai_hub_models.models.squeezenet1_1_quantized](qai_hub_models/models/squeezenet1_1_quantized/README.md) | ✔️ | ✔️ | ✔️ | [DenseNet-121](https://aihub.qualcomm.com/models/densenet121) | [qai_hub_models.models.densenet121](qai_hub_models/models/densenet121/README.md) | ✔️ | ✔️ | ✔️ +| [ResNet50](https://aihub.qualcomm.com/models/resnet50) | [qai_hub_models.models.resnet50](qai_hub_models/models/resnet50/README.md) | ✔️ | ✔️ | ✔️ | [ResNet101Quantized](https://aihub.qualcomm.com/models/resnet101_quantized) | [qai_hub_models.models.resnet101_quantized](qai_hub_models/models/resnet101_quantized/README.md) | ✔️ | ✔️ | ✔️ -| [ResNet18](https://aihub.qualcomm.com/models/resnet18) | [qai_hub_models.models.resnet18](qai_hub_models/models/resnet18/README.md) | ✔️ | ✔️ | ✔️ -| [ResNet101](https://aihub.qualcomm.com/models/resnet101) | [qai_hub_models.models.resnet101](qai_hub_models/models/resnet101/README.md) | ✔️ | ✔️ | ✔️ -| [Swin-Tiny](https://aihub.qualcomm.com/models/swin_tiny) | [qai_hub_models.models.swin_tiny](qai_hub_models/models/swin_tiny/README.md) | ✔️ | ✔️ | ✔️ -| [WideResNet50](https://aihub.qualcomm.com/models/wideresnet50) | [qai_hub_models.models.wideresnet50](qai_hub_models/models/wideresnet50/README.md) | ✔️ | ✔️ | ✔️ -| [ResNet18Quantized](https://aihub.qualcomm.com/models/resnet18_quantized) | [qai_hub_models.models.resnet18_quantized](qai_hub_models/models/resnet18_quantized/README.md) | ✔️ | ✔️ | ✔️ -| [MobileNet-v2](https://aihub.qualcomm.com/models/mobilenet_v2) | [qai_hub_models.models.mobilenet_v2](qai_hub_models/models/mobilenet_v2/README.md) | ✔️ | ✔️ | ✔️ -| [VIT](https://aihub.qualcomm.com/models/vit) | [qai_hub_models.models.vit](qai_hub_models/models/vit/README.md) | ✔️ | ✔️ | ✔️ -| [ResNeXt50](https://aihub.qualcomm.com/models/resnext50) | [qai_hub_models.models.resnext50](qai_hub_models/models/resnext50/README.md) | ✔️ | ✔️ | ✔️ -| [EfficientNet-B0](https://aihub.qualcomm.com/models/efficientnet_b0) | [qai_hub_models.models.efficientnet_b0](qai_hub_models/models/efficientnet_b0/README.md) | ✔️ | ✔️ | ✔️ -| [Inception-v3Quantized](https://aihub.qualcomm.com/models/inception_v3_quantized) | [qai_hub_models.models.inception_v3_quantized](qai_hub_models/models/inception_v3_quantized/README.md) | ✔️ | ✔️ | ✔️ -| [ConvNext-Tiny](https://aihub.qualcomm.com/models/convnext_tiny) | [qai_hub_models.models.convnext_tiny](qai_hub_models/models/convnext_tiny/README.md) | ✔️ | ✔️ | ✔️ -| [ResNeXt101](https://aihub.qualcomm.com/models/resnext101) | [qai_hub_models.models.resnext101](qai_hub_models/models/resnext101/README.md) | ✔️ | ✔️ | ✔️ -| [Shufflenet-v2](https://aihub.qualcomm.com/models/shufflenet_v2) | [qai_hub_models.models.shufflenet_v2](qai_hub_models/models/shufflenet_v2/README.md) | ✔️ | ✔️ | ✔️ -| [Shufflenet-v2Quantized](https://aihub.qualcomm.com/models/shufflenet_v2_quantized) | [qai_hub_models.models.shufflenet_v2_quantized](qai_hub_models/models/shufflenet_v2_quantized/README.md) | ✔️ | ✔️ | ✔️ -| [SqueezeNet-1_1](https://aihub.qualcomm.com/models/squeezenet1_1) | [qai_hub_models.models.squeezenet1_1](qai_hub_models/models/squeezenet1_1/README.md) | ✔️ | ✔️ | ✔️ -| [GoogLeNet](https://aihub.qualcomm.com/models/googlenet) | [qai_hub_models.models.googlenet](qai_hub_models/models/googlenet/README.md) | ✔️ | ✔️ | ✔️ -| [Inception-v3](https://aihub.qualcomm.com/models/inception_v3) | [qai_hub_models.models.inception_v3](qai_hub_models/models/inception_v3/README.md) | ✔️ | ✔️ | ✔️ | | | | | | **Image Editing** | [LaMa-Dilated](https://aihub.qualcomm.com/models/lama_dilated) | [qai_hub_models.models.lama_dilated](qai_hub_models/models/lama_dilated/README.md) | ✔️ | ✔️ | ✔️ @@ -292,53 +292,53 @@ For any issues, please contact us at ai-hub-support@qti.qualcomm.com. | | | | | | **Super Resolution** | [QuickSRNetLarge](https://aihub.qualcomm.com/models/quicksrnetlarge) | [qai_hub_models.models.quicksrnetlarge](qai_hub_models/models/quicksrnetlarge/README.md) | ✔️ | ✔️ | ✔️ -| [XLSR-Quantized](https://aihub.qualcomm.com/models/xlsr_quantized) | [qai_hub_models.models.xlsr_quantized](qai_hub_models/models/xlsr_quantized/README.md) | ✔️ | ✔️ | ✔️ | [QuickSRNetMedium](https://aihub.qualcomm.com/models/quicksrnetmedium) | [qai_hub_models.models.quicksrnetmedium](qai_hub_models/models/quicksrnetmedium/README.md) | ✔️ | ✔️ | ✔️ -| [SESR-M5](https://aihub.qualcomm.com/models/sesr_m5) | [qai_hub_models.models.sesr_m5](qai_hub_models/models/sesr_m5/README.md) | ✔️ | ✔️ | ✔️ -| [XLSR](https://aihub.qualcomm.com/models/xlsr) | [qai_hub_models.models.xlsr](qai_hub_models/models/xlsr/README.md) | ✔️ | ✔️ | ✔️ -| [Real-ESRGAN-General-x4v3](https://aihub.qualcomm.com/models/real_esrgan_general_x4v3) | [qai_hub_models.models.real_esrgan_general_x4v3](qai_hub_models/models/real_esrgan_general_x4v3/README.md) | ✔️ | ✔️ | ✔️ -| [QuickSRNetSmall](https://aihub.qualcomm.com/models/quicksrnetsmall) | [qai_hub_models.models.quicksrnetsmall](qai_hub_models/models/quicksrnetsmall/README.md) | ✔️ | ✔️ | ✔️ | [SESR-M5-Quantized](https://aihub.qualcomm.com/models/sesr_m5_quantized) | [qai_hub_models.models.sesr_m5_quantized](qai_hub_models/models/sesr_m5_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [QuickSRNetSmall](https://aihub.qualcomm.com/models/quicksrnetsmall) | [qai_hub_models.models.quicksrnetsmall](qai_hub_models/models/quicksrnetsmall/README.md) | ✔️ | ✔️ | ✔️ +| [SESR-M5](https://aihub.qualcomm.com/models/sesr_m5) | [qai_hub_models.models.sesr_m5](qai_hub_models/models/sesr_m5/README.md) | ✔️ | ✔️ | ✔️ | [Real-ESRGAN-x4plus](https://aihub.qualcomm.com/models/real_esrgan_x4plus) | [qai_hub_models.models.real_esrgan_x4plus](qai_hub_models/models/real_esrgan_x4plus/README.md) | ✔️ | ✔️ | ✔️ +| [Real-ESRGAN-General-x4v3](https://aihub.qualcomm.com/models/real_esrgan_general_x4v3) | [qai_hub_models.models.real_esrgan_general_x4v3](qai_hub_models/models/real_esrgan_general_x4v3/README.md) | ✔️ | ✔️ | ✔️ +| [XLSR-Quantized](https://aihub.qualcomm.com/models/xlsr_quantized) | [qai_hub_models.models.xlsr_quantized](qai_hub_models/models/xlsr_quantized/README.md) | ✔️ | ✔️ | ✔️ | [ESRGAN](https://aihub.qualcomm.com/models/esrgan) | [qai_hub_models.models.esrgan](qai_hub_models/models/esrgan/README.md) | ✔️ | ✔️ | ✔️ +| [XLSR](https://aihub.qualcomm.com/models/xlsr) | [qai_hub_models.models.xlsr](qai_hub_models/models/xlsr/README.md) | ✔️ | ✔️ | ✔️ | | | | | | **Semantic Segmentation** +| [FFNet-78S-Quantized](https://aihub.qualcomm.com/models/ffnet_78s_quantized) | [qai_hub_models.models.ffnet_78s_quantized](qai_hub_models/models/ffnet_78s_quantized/README.md) | ✔️ | ✔️ | ✔️ | [FFNet-40S-Quantized](https://aihub.qualcomm.com/models/ffnet_40s_quantized) | [qai_hub_models.models.ffnet_40s_quantized](qai_hub_models/models/ffnet_40s_quantized/README.md) | ✔️ | ✔️ | ✔️ -| [FFNet-54S](https://aihub.qualcomm.com/models/ffnet_54s) | [qai_hub_models.models.ffnet_54s](qai_hub_models/models/ffnet_54s/README.md) | ✔️ | ✔️ | ✔️ | [DDRNet23-Slim](https://aihub.qualcomm.com/models/ddrnet23_slim) | [qai_hub_models.models.ddrnet23_slim](qai_hub_models/models/ddrnet23_slim/README.md) | ✔️ | ✔️ | ✔️ -| [Yolo-v8-Segmentation](https://aihub.qualcomm.com/models/yolov8_seg) | [qai_hub_models.models.yolov8_seg](qai_hub_models/models/yolov8_seg/README.md) | ✔️ | ✔️ | ✔️ +| [FFNet-54S](https://aihub.qualcomm.com/models/ffnet_54s) | [qai_hub_models.models.ffnet_54s](qai_hub_models/models/ffnet_54s/README.md) | ✔️ | ✔️ | ✔️ +| [FFNet-78S](https://aihub.qualcomm.com/models/ffnet_78s) | [qai_hub_models.models.ffnet_78s](qai_hub_models/models/ffnet_78s/README.md) | ✔️ | ✔️ | ✔️ | [FFNet-54S-Quantized](https://aihub.qualcomm.com/models/ffnet_54s_quantized) | [qai_hub_models.models.ffnet_54s_quantized](qai_hub_models/models/ffnet_54s_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [FCN_ResNet50](https://aihub.qualcomm.com/models/fcn_resnet50) | [qai_hub_models.models.fcn_resnet50](qai_hub_models/models/fcn_resnet50/README.md) | ✔️ | ✔️ | ✔️ +| [FastSam-S](https://aihub.qualcomm.com/models/fastsam_s) | [qai_hub_models.models.fastsam_s](qai_hub_models/models/fastsam_s/README.md) | ✔️ | ✔️ | ✔️ +| [MediaPipe-Selfie-Segmentation](https://aihub.qualcomm.com/models/mediapipe_selfie) | [qai_hub_models.models.mediapipe_selfie](qai_hub_models/models/mediapipe_selfie/README.md) | ✔️ | ✔️ | ✔️ +| [FFNet-122NS-LowRes](https://aihub.qualcomm.com/models/ffnet_122ns_lowres) | [qai_hub_models.models.ffnet_122ns_lowres](qai_hub_models/models/ffnet_122ns_lowres/README.md) | ✔️ | ✔️ | ✔️ | [SINet](https://aihub.qualcomm.com/models/sinet) | [qai_hub_models.models.sinet](qai_hub_models/models/sinet/README.md) | ✔️ | ✔️ | ✔️ | [FFNet-40S](https://aihub.qualcomm.com/models/ffnet_40s) | [qai_hub_models.models.ffnet_40s](qai_hub_models/models/ffnet_40s/README.md) | ✔️ | ✔️ | ✔️ -| [FFNet-78S](https://aihub.qualcomm.com/models/ffnet_78s) | [qai_hub_models.models.ffnet_78s](qai_hub_models/models/ffnet_78s/README.md) | ✔️ | ✔️ | ✔️ -| [FFNet-78S-LowRes](https://aihub.qualcomm.com/models/ffnet_78s_lowres) | [qai_hub_models.models.ffnet_78s_lowres](qai_hub_models/models/ffnet_78s_lowres/README.md) | ✔️ | ✔️ | ✔️ +| [Yolo-v8-Segmentation](https://aihub.qualcomm.com/models/yolov8_seg) | [qai_hub_models.models.yolov8_seg](qai_hub_models/models/yolov8_seg/README.md) | ✔️ | ✔️ | ✔️ | [DeepLabV3-ResNet50](https://aihub.qualcomm.com/models/deeplabv3_resnet50) | [qai_hub_models.models.deeplabv3_resnet50](qai_hub_models/models/deeplabv3_resnet50/README.md) | ✔️ | ✔️ | ✔️ -| [FFNet-78S-Quantized](https://aihub.qualcomm.com/models/ffnet_78s_quantized) | [qai_hub_models.models.ffnet_78s_quantized](qai_hub_models/models/ffnet_78s_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [FastSam-X](https://aihub.qualcomm.com/models/fastsam_x) | [qai_hub_models.models.fastsam_x](qai_hub_models/models/fastsam_x/README.md) | ✔️ | ✔️ | ✔️ +| [FFNet-78S-LowRes](https://aihub.qualcomm.com/models/ffnet_78s_lowres) | [qai_hub_models.models.ffnet_78s_lowres](qai_hub_models/models/ffnet_78s_lowres/README.md) | ✔️ | ✔️ | ✔️ | [Unet-Segmentation](https://aihub.qualcomm.com/models/unet_segmentation) | [qai_hub_models.models.unet_segmentation](qai_hub_models/models/unet_segmentation/README.md) | ✔️ | ✔️ | ✔️ | [Segment-Anything-Model](https://aihub.qualcomm.com/models/sam) | [qai_hub_models.models.sam](qai_hub_models/models/sam/README.md) | ✔️ | ✔️ | ✔️ -| [FFNet-122NS-LowRes](https://aihub.qualcomm.com/models/ffnet_122ns_lowres) | [qai_hub_models.models.ffnet_122ns_lowres](qai_hub_models/models/ffnet_122ns_lowres/README.md) | ✔️ | ✔️ | ✔️ -| [FastSam-S](https://aihub.qualcomm.com/models/fastsam_s) | [qai_hub_models.models.fastsam_s](qai_hub_models/models/fastsam_s/README.md) | ✔️ | ✔️ | ✔️ -| [FCN_ResNet50](https://aihub.qualcomm.com/models/fcn_resnet50) | [qai_hub_models.models.fcn_resnet50](qai_hub_models/models/fcn_resnet50/README.md) | ✔️ | ✔️ | ✔️ -| [MediaPipe-Selfie-Segmentation](https://aihub.qualcomm.com/models/mediapipe_selfie) | [qai_hub_models.models.mediapipe_selfie](qai_hub_models/models/mediapipe_selfie/README.md) | ✔️ | ✔️ | ✔️ -| [FastSam-X](https://aihub.qualcomm.com/models/fastsam_x) | [qai_hub_models.models.fastsam_x](qai_hub_models/models/fastsam_x/README.md) | ✔️ | ✔️ | ✔️ | | | | | | **Object Detection** -| [MediaPipe-Hand-Detection](https://aihub.qualcomm.com/models/mediapipe_hand) | [qai_hub_models.models.mediapipe_hand](qai_hub_models/models/mediapipe_hand/README.md) | ✔️ | ✔️ | ✔️ -| [Yolo-v8-Detection](https://aihub.qualcomm.com/models/yolov8_det) | [qai_hub_models.models.yolov8_det](qai_hub_models/models/yolov8_det/README.md) | ✔️ | ✔️ | ✔️ | [DETR-ResNet50-DC5](https://aihub.qualcomm.com/models/detr_resnet50_dc5) | [qai_hub_models.models.detr_resnet50_dc5](qai_hub_models/models/detr_resnet50_dc5/README.md) | ✔️ | ✔️ | ✔️ -| [DETR-ResNet101-DC5](https://aihub.qualcomm.com/models/detr_resnet101_dc5) | [qai_hub_models.models.detr_resnet101_dc5](qai_hub_models/models/detr_resnet101_dc5/README.md) | ✔️ | ✔️ | ✔️ | [DETR-ResNet50](https://aihub.qualcomm.com/models/detr_resnet50) | [qai_hub_models.models.detr_resnet50](qai_hub_models/models/detr_resnet50/README.md) | ✔️ | ✔️ | ✔️ +| [Yolo-v8-Detection](https://aihub.qualcomm.com/models/yolov8_det) | [qai_hub_models.models.yolov8_det](qai_hub_models/models/yolov8_det/README.md) | ✔️ | ✔️ | ✔️ +| [DETR-ResNet101](https://aihub.qualcomm.com/models/detr_resnet101) | [qai_hub_models.models.detr_resnet101](qai_hub_models/models/detr_resnet101/README.md) | ✔️ | ✔️ | ✔️ +| [MediaPipe-Face-Detection](https://aihub.qualcomm.com/models/mediapipe_face) | [qai_hub_models.models.mediapipe_face](qai_hub_models/models/mediapipe_face/README.md) | ✔️ | ✔️ | ✔️ +| [MediaPipe-Hand-Detection](https://aihub.qualcomm.com/models/mediapipe_hand) | [qai_hub_models.models.mediapipe_hand](qai_hub_models/models/mediapipe_hand/README.md) | ✔️ | ✔️ | ✔️ | [Yolo-v7](https://aihub.qualcomm.com/models/yolov7) | [qai_hub_models.models.yolov7](qai_hub_models/models/yolov7/README.md) | ✔️ | ✔️ | ✔️ +| [DETR-ResNet101-DC5](https://aihub.qualcomm.com/models/detr_resnet101_dc5) | [qai_hub_models.models.detr_resnet101_dc5](qai_hub_models/models/detr_resnet101_dc5/README.md) | ✔️ | ✔️ | ✔️ | [Yolo-v6](https://aihub.qualcomm.com/models/yolov6) | [qai_hub_models.models.yolov6](qai_hub_models/models/yolov6/README.md) | ✔️ | ✔️ | ✔️ -| [MediaPipe-Face-Detection](https://aihub.qualcomm.com/models/mediapipe_face) | [qai_hub_models.models.mediapipe_face](qai_hub_models/models/mediapipe_face/README.md) | ✔️ | ✔️ | ✔️ -| [DETR-ResNet101](https://aihub.qualcomm.com/models/detr_resnet101) | [qai_hub_models.models.detr_resnet101](qai_hub_models/models/detr_resnet101/README.md) | ✔️ | ✔️ | ✔️ | | | | | | **Pose Estimation** -| [OpenPose](https://aihub.qualcomm.com/models/openpose) | [qai_hub_models.models.openpose](qai_hub_models/models/openpose/README.md) | ✔️ | ✔️ | ✔️ -| [MediaPipe-Pose-Estimation](https://aihub.qualcomm.com/models/mediapipe_pose) | [qai_hub_models.models.mediapipe_pose](qai_hub_models/models/mediapipe_pose/README.md) | ✔️ | ✔️ | ✔️ +| [HRNetPose](https://aihub.qualcomm.com/models/hrnet_pose) | [qai_hub_models.models.hrnet_pose](qai_hub_models/models/hrnet_pose/README.md) | ✔️ | ✔️ | ✔️ | [HRNetPoseQuantized](https://aihub.qualcomm.com/models/hrnet_pose_quantized) | [qai_hub_models.models.hrnet_pose_quantized](qai_hub_models/models/hrnet_pose_quantized/README.md) | ✔️ | ✔️ | ✔️ | [LiteHRNet](https://aihub.qualcomm.com/models/litehrnet) | [qai_hub_models.models.litehrnet](qai_hub_models/models/litehrnet/README.md) | ✔️ | ✔️ | ✔️ -| [HRNetPose](https://aihub.qualcomm.com/models/hrnet_pose) | [qai_hub_models.models.hrnet_pose](qai_hub_models/models/hrnet_pose/README.md) | ✔️ | ✔️ | ✔️ +| [OpenPose](https://aihub.qualcomm.com/models/openpose) | [qai_hub_models.models.openpose](qai_hub_models/models/openpose/README.md) | ✔️ | ✔️ | ✔️ +| [MediaPipe-Pose-Estimation](https://aihub.qualcomm.com/models/mediapipe_pose) | [qai_hub_models.models.mediapipe_pose](qai_hub_models/models/mediapipe_pose/README.md) | ✔️ | ✔️ | ✔️ ### Audio @@ -346,8 +346,8 @@ For any issues, please contact us at ai-hub-support@qti.qualcomm.com. | -- | -- | -- | -- | -- | | | | | | **Speech Recognition** -| [HuggingFace-WavLM-Base-Plus](https://aihub.qualcomm.com/models/huggingface_wavlm_base_plus) | [qai_hub_models.models.huggingface_wavlm_base_plus](qai_hub_models/models/huggingface_wavlm_base_plus/README.md) | ✔️ | ✔️ | ✔️ | [Whisper-Base](https://aihub.qualcomm.com/models/whisper_asr) | [qai_hub_models.models.whisper_asr](qai_hub_models/models/whisper_asr/README.md) | ✔️ | ✔️ | ✔️ +| [HuggingFace-WavLM-Base-Plus](https://aihub.qualcomm.com/models/huggingface_wavlm_base_plus) | [qai_hub_models.models.huggingface_wavlm_base_plus](qai_hub_models/models/huggingface_wavlm_base_plus/README.md) | ✔️ | ✔️ | ✔️ | | | | | | **Audio Enhancement** | [Facebook-Denoiser](https://aihub.qualcomm.com/models/facebook_denoiser) | [qai_hub_models.models.facebook_denoiser](qai_hub_models/models/facebook_denoiser/README.md) | ✔️ | ✔️ | ✔️ @@ -357,8 +357,8 @@ For any issues, please contact us at ai-hub-support@qti.qualcomm.com. | Model | README | Torch App | Device Export | CLI Demo | -- | -- | -- | -- | -- | | | | | -| [OpenAI-Clip](https://aihub.qualcomm.com/models/openai_clip) | [qai_hub_models.models.openai_clip](qai_hub_models/models/openai_clip/README.md) | ✔️ | ✔️ | ✔️ | [TrOCR](https://aihub.qualcomm.com/models/trocr) | [qai_hub_models.models.trocr](qai_hub_models/models/trocr/README.md) | ✔️ | ✔️ | ✔️ +| [OpenAI-Clip](https://aihub.qualcomm.com/models/openai_clip) | [qai_hub_models.models.openai_clip](qai_hub_models/models/openai_clip/README.md) | ✔️ | ✔️ | ✔️ ### Generative Ai @@ -366,8 +366,9 @@ For any issues, please contact us at ai-hub-support@qti.qualcomm.com. | -- | -- | -- | -- | -- | | | | | | **Image Generation** -| [ControlNet](https://aihub.qualcomm.com/models/controlnet_quantized) | [qai_hub_models.models.controlnet_quantized](qai_hub_models/models/controlnet_quantized/README.md) | ✔️ | ✔️ | ✔️ | [Stable-Diffusion](https://aihub.qualcomm.com/models/stable_diffusion_quantized) | [qai_hub_models.models.stable_diffusion_quantized](qai_hub_models/models/stable_diffusion_quantized/README.md) | ✔️ | ✔️ | ✔️ +| [ControlNet](https://aihub.qualcomm.com/models/controlnet_quantized) | [qai_hub_models.models.controlnet_quantized](qai_hub_models/models/controlnet_quantized/README.md) | ✔️ | ✔️ | ✔️ | | | | | | **Text Generation** +| [Llama-v2-7B-Chat](https://aihub.qualcomm.com/models/llama_v2_7b_chat_quantized) | [qai_hub_models.models.llama_v2_7b_chat_quantized](qai_hub_models/models/llama_v2_7b_chat_quantized/README.md) | ✔️ | ✔️ | ✔️ | [Baichuan-7B](https://aihub.qualcomm.com/models/baichuan_7b_quantized) | [qai_hub_models.models.baichuan_7b_quantized](qai_hub_models/models/baichuan_7b_quantized/README.md) | ✔️ | ✔️ | ✔️ diff --git a/mypy.ini b/mypy.ini index bac83c81..7e2ee8c7 100644 --- a/mypy.ini +++ b/mypy.ini @@ -74,5 +74,11 @@ ignore_missing_imports = True [mypy-ruamel.*] ignore_missing_imports = True +[mypy-pandas.*] +ignore_missing_imports = True + +[mypy-tabulate.*] +ignore_missing_imports = True + [mypy-qai_hub_models.models.*] ignore_errors = true diff --git a/qai_hub_models/_version.py b/qai_hub_models/_version.py index 2946e3c0..19465d64 100644 --- a/qai_hub_models/_version.py +++ b/qai_hub_models/_version.py @@ -2,4 +2,4 @@ # Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. # SPDX-License-Identifier: BSD-3-Clause # --------------------------------------------------------------------- -__version__ = "0.3.0" +__version__ = "0.3.1" diff --git a/qai_hub_models/datasets/imagenette.py b/qai_hub_models/datasets/imagenette.py index 646bbb62..05bdc09e 100644 --- a/qai_hub_models/datasets/imagenette.py +++ b/qai_hub_models/datasets/imagenette.py @@ -8,7 +8,6 @@ from torchvision.datasets import ImageNet from qai_hub_models.datasets.common import BaseDataset -from qai_hub_models.models._shared.imagenet_classifier.app import IMAGENET_TRANSFORM from qai_hub_models.utils.asset_loaders import CachedWebDatasetAsset IMAGENETTE_FOLDER_NAME = "imagenette2-320" @@ -53,6 +52,11 @@ class ImagenetteDataset(BaseDataset, ImageNet): def __init__(self): self._download_data() BaseDataset.__init__(self, str(IMAGENETTE_ASSET.path(extracted=True))) + # Avoid circular import + from qai_hub_models.models._shared.imagenet_classifier.app import ( + IMAGENET_TRANSFORM, + ) + ImageNet.__init__( self, root=IMAGENETTE_ASSET.path(), @@ -94,7 +98,6 @@ def _download_data(self) -> None: devkit_path = DEVKIT_ASSET.fetch() devkit_st = os.stat(devkit_path) os.chmod(devkit_path, devkit_st.st_mode | stat.S_IEXEC) - os.symlink( - DEVKIT_ASSET.path(), - IMAGENETTE_ASSET.path() / os.path.basename(DEVKIT_ASSET.path()), - ) + target_path = IMAGENETTE_ASSET.path() / os.path.basename(DEVKIT_ASSET.path()) + if not os.path.exists(target_path): + os.symlink(DEVKIT_ASSET.path(), target_path) diff --git a/qai_hub_models/models/_shared/cityscapes_segmentation/demo.py b/qai_hub_models/models/_shared/cityscapes_segmentation/demo.py index 25630f71..4fb3518d 100644 --- a/qai_hub_models/models/_shared/cityscapes_segmentation/demo.py +++ b/qai_hub_models/models/_shared/cityscapes_segmentation/demo.py @@ -14,13 +14,13 @@ CityscapesSegmentor, ) from qai_hub_models.utils.args import ( - TargetRuntime, 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.base_model import TargetRuntime from qai_hub_models.utils.display import display_or_save_image from qai_hub_models.utils.image_processing import pil_resize_pad, pil_undo_resize_pad @@ -65,13 +65,15 @@ def cityscapes_segmentation_demo( (_, _, height, width) = input_spec["image"][0] orig_image = load_image(image) - image, _, padding = pil_resize_pad(orig_image, (height, width)) + image, scale, padding = pil_resize_pad(orig_image, (height, width)) # Run app image_annotated = app.predict(image) # Resize / unpad annotated image - image_annotated = pil_undo_resize_pad(image_annotated, orig_image.size, padding) + image_annotated = pil_undo_resize_pad( + image_annotated, orig_image.size, scale, padding + ) if not is_test: display_or_save_image( diff --git a/qai_hub_models/models/_shared/deeplab/demo.py b/qai_hub_models/models/_shared/deeplab/demo.py index ccdc20c3..a14b7064 100644 --- a/qai_hub_models/models/_shared/deeplab/demo.py +++ b/qai_hub_models/models/_shared/deeplab/demo.py @@ -8,13 +8,15 @@ from qai_hub_models.models._shared.deeplab.app import DeepLabV3App from qai_hub_models.utils.args import ( - add_output_dir_arg, + demo_model_from_cli_args, get_model_cli_parser, - model_from_cli_args, + get_on_device_demo_parser, + validate_on_device_demo_args, ) from qai_hub_models.utils.asset_loaders import CachedWebAsset, load_image from qai_hub_models.utils.base_model import BaseModel from qai_hub_models.utils.display import display_or_save_image +from qai_hub_models.utils.image_processing import pil_resize_pad, pil_undo_resize_pad def deeplabv3_demo( @@ -25,21 +27,38 @@ def deeplabv3_demo( ): # Demo parameters parser = get_model_cli_parser(model_type) + parser = get_on_device_demo_parser(parser, add_output_dir=True) parser.add_argument( "--image", type=str, default=default_image, help="image file path or URL.", ) - add_output_dir_arg(parser) args = parser.parse_args([] if is_test else None) + validate_on_device_demo_args(args, model_type.get_model_id()) + + input_spec = model_type.get_input_spec() + + # load image and model + (_, _, height, width) = input_spec["image"][0] + orig_image = load_image(args.image) + image, scale, padding = pil_resize_pad(orig_image, (height, width)) # This DeepLabV3 ResNet 50 demo comes from # https://pytorch.org/hub/pytorch_vision_deeplabv3_resnet101/ - # load image and model - image = load_image(args.image) input_image = image.convert("RGB") - app = DeepLabV3App(model_from_cli_args(model_type, args), num_classes=num_classes) - output = app.predict(input_image, False) + inference_model = demo_model_from_cli_args(model_type, args) + app = DeepLabV3App(inference_model, num_classes=num_classes) + + # Run app + image_annotated = app.predict(input_image, False) + + # Resize / unpad annotated image + image_annotated = pil_undo_resize_pad( + image_annotated, orig_image.size, scale, padding + ) + if not is_test: - display_or_save_image(output, args.output_dir) + display_or_save_image( + image_annotated, args.output_dir, "annotated_image", "predicted image" + ) diff --git a/qai_hub_models/models/_shared/ffnet_quantized/model.py b/qai_hub_models/models/_shared/ffnet_quantized/model.py index 54cb1ee2..ebf4a04b 100644 --- a/qai_hub_models/models/_shared/ffnet_quantized/model.py +++ b/qai_hub_models/models/_shared/ffnet_quantized/model.py @@ -4,6 +4,14 @@ # --------------------------------------------------------------------- from __future__ import annotations +# isort: off +# This verifies aimet is installed, and this must be included first. +from qai_hub_models.utils.quantization_aimet import ( + AIMETQuantizableMixin, +) + +# isort: on + import os import torch @@ -15,7 +23,6 @@ from qai_hub_models.models._shared.ffnet.model import FFNet from qai_hub_models.utils.base_model import SourceModelFormat, TargetRuntime from qai_hub_models.utils.input_spec import InputSpec -from qai_hub_models.utils.quantization_aimet import AIMETQuantizableMixin MODEL_ID = __name__.split(".")[-2] FFNET_AIMET_CONFIG = os.path.abspath( diff --git a/qai_hub_models/models/_shared/imagenet_classifier/model.py b/qai_hub_models/models/_shared/imagenet_classifier/model.py index 516b7dca..dd896cdf 100644 --- a/qai_hub_models/models/_shared/imagenet_classifier/model.py +++ b/qai_hub_models/models/_shared/imagenet_classifier/model.py @@ -4,10 +4,12 @@ # --------------------------------------------------------------------- from __future__ import annotations -from typing import Optional +from typing import Dict, List, Optional +import numpy as np import torch +from qai_hub_models.datasets.imagenette import ImagenetteDataset from qai_hub_models.evaluators.base_evaluators import BaseEvaluator from qai_hub_models.evaluators.classification_evaluator import ClassificationEvaluator from qai_hub_models.utils.base_model import BaseModel @@ -73,3 +75,9 @@ def from_pretrained( ) -> "ImagenetClassifier": net = cls.model_builder(weights=weights or cls.DEFAULT_WEIGHTS) return cls(net) + + def sample_inputs( + self, input_spec: InputSpec | None = None + ) -> Dict[str, List[np.ndarray]]: + dataset = ImagenetteDataset() + return dict(image_tensor=[dataset[42][0].numpy()[None, :, :, :]]) diff --git a/qai_hub_models/models/baichuan_7b_quantized/README.md b/qai_hub_models/models/baichuan_7b_quantized/README.md index ba681122..8f2fd60c 100644 --- a/qai_hub_models/models/baichuan_7b_quantized/README.md +++ b/qai_hub_models/models/baichuan_7b_quantized/README.md @@ -16,12 +16,16 @@ a hosted Qualcomm® device. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Baichuan-7B can be found [here](https://github.com/baichuan-inc/Baichuan-7B/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Baichuan 2: Open Large-scale Language Models](https://arxiv.org/abs/2309.10305) * [Source Model Implementation](https://github.com/baichuan-inc/Baichuan-7B/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/controlnet_quantized/README.md b/qai_hub_models/models/controlnet_quantized/README.md index bde72516..32cfbb02 100644 --- a/qai_hub_models/models/controlnet_quantized/README.md +++ b/qai_hub_models/models/controlnet_quantized/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ControlNet can be found [here](https://github.com/lllyasviel/ControlNet/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Adding Conditional Control to Text-to-Image Diffusion Models](https://arxiv.org/abs/2302.05543) * [Source Model Implementation](https://github.com/lllyasviel/ControlNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/controlnet_quantized/demo.py b/qai_hub_models/models/controlnet_quantized/demo.py index 0f22452b..c1f41ae6 100644 --- a/qai_hub_models/models/controlnet_quantized/demo.py +++ b/qai_hub_models/models/controlnet_quantized/demo.py @@ -23,7 +23,7 @@ from qai_hub_models.utils.asset_loaders import CachedWebModelAsset, load_image from qai_hub_models.utils.base_model import BasePrecompiledModel from qai_hub_models.utils.display import display_or_save_image -from qai_hub_models.utils.inference import HubModel +from qai_hub_models.utils.inference import HubModel, get_uploaded_precompiled_model from qai_hub_models.utils.qai_hub_helpers import can_access_qualcomm_ai_hub INPUT_IMAGE = CachedWebModelAsset.from_asset_store( @@ -31,9 +31,15 @@ ).fetch() DEFAULT_DEMO_PROMPT = "a white bird on a colorful window" +DEFAULT_DEVICE_NAME = "Samsung Galaxy S23 Ultra" -def _get_hub_model(input_model: BasePrecompiledModel, device=DEFAULT_EXPORT_DEVICE): +def _get_hub_model( + input_model: BasePrecompiledModel, + model_name: str, + ignore_cached_model: bool = False, + device_name=DEFAULT_DEVICE_NAME, +): if not can_access_qualcomm_ai_hub(): raise RuntimeError( "ControlNet on-device demo requires access to QAI-Hub.\n" @@ -41,9 +47,15 @@ def _get_hub_model(input_model: BasePrecompiledModel, device=DEFAULT_EXPORT_DEVI ) # Upload model - uploaded_model = hub.upload_model(input_model.get_target_model_path()) + uploaded_model = get_uploaded_precompiled_model( + input_model.get_target_model_path(), + MODEL_ID, + MODEL_ASSET_VERSION, + model_name, + ignore_cached_model=ignore_cached_model, + ) inputs = list(input_model.get_input_spec().keys()) - return HubModel(uploaded_model, inputs, hub.Device(name=device)) + return HubModel(uploaded_model, inputs, hub.Device(name=device_name)) # Run ControlNet end-to-end on a given prompt and input image. @@ -82,7 +94,12 @@ def main(is_test: bool = False): help="Strength of guidance (higher means more influence from prompt).", ) parser.add_argument( - "--device", + "--ignore-cached-model", + action="store_true", + help="Uploads model ignoring previously uploaded and cached model.", + ) + parser.add_argument( + "--device-name", type=str, default=DEFAULT_EXPORT_DEVICE, help="Device to run stable-diffusion demo on.", @@ -92,7 +109,7 @@ def main(is_test: bool = False): if not is_test: print(f"\n{'-' * 100}") print( - f"** Performing image generation on-device({args.device}) with ControlNet - Stable Diffusion **" + f"** Performing image generation on-device({args.device_name}) with ControlNet - Stable Diffusion **" ) print() print("Prompt:", args.prompt) @@ -102,7 +119,7 @@ def main(is_test: bool = False): print("Seed:", args.seed) print() print( - "Note: This reference demo uses significant amounts of memory and may take 5-10 minutes to run per step." + "Note: This reference demo uses significant amounts of memory and may take 5-10 minutes to run ** per step **." ) print(f"{'-' * 100}\n") @@ -118,10 +135,16 @@ def main(is_test: bool = False): # Instead of forward, we later submit inference_jobs on QAI-Hub for # on-device evaluation. print(f"Uploading model assets on QAI-Hub\n{'-' * 35}") - text_encoder = _get_hub_model(text_encoder, args.device) - unet = _get_hub_model(unet, args.device) - vae_decoder = _get_hub_model(vae_decoder, args.device) - controlnet = _get_hub_model(controlnet, args.device) + text_encoder = _get_hub_model( + text_encoder, "text_encoder", args.ignore_cached_model, args.device_name + ) + unet = _get_hub_model(unet, "unet", args.ignore_cached_model, args.device_name) + vae_decoder = _get_hub_model( + vae_decoder, "vae_decoder", args.ignore_cached_model, args.device_name + ) + controlnet = _get_hub_model( + controlnet, "controlnet", args.ignore_cached_model, args.device_name + ) # Create tokenizer, scheduler and time_embedding required # for control-net pipeline. diff --git a/qai_hub_models/models/controlnet_quantized/export.py b/qai_hub_models/models/controlnet_quantized/export.py index 01cb4b9b..b83cfb58 100644 --- a/qai_hub_models/models/controlnet_quantized/export.py +++ b/qai_hub_models/models/controlnet_quantized/export.py @@ -14,15 +14,26 @@ import qai_hub as hub from qai_hub_models.models.controlnet_quantized import Model -from qai_hub_models.utils.args import TargetRuntime, export_parser +from qai_hub_models.utils.args import export_parser +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.printing import print_profile_metrics_from_job from qai_hub_models.utils.qai_hub_helpers import ( can_access_qualcomm_ai_hub, export_without_hub_access, ) -ALL_COMPONENTS = ["text_encoder", "unet", "vae_decoder", "controlnet"] -DEFAULT_COMPONENTS = ["text_encoder", "vae_decoder", "unet", "controlnet"] +ALL_COMPONENTS = [ + "Text-Encoder-Quantized", + "UNet-Quantized", + "VAE-Decoder-Quantized", + "ControlNet-Quantized", +] +DEFAULT_COMPONENTS = [ + "Text-Encoder-Quantized", + "VAE-Decoder-Quantized", + "UNet-Quantized", + "ControlNet-Quantized", +] def export_model( @@ -97,14 +108,14 @@ def export_model( print("Initializing model class") model = Model.from_precompiled() components_dict = {} - if "text_encoder" in components: - components_dict["text_encoder"] = model.text_encoder - if "unet" in components: - components_dict["unet"] = model.unet - if "vae_decoder" in components: - components_dict["vae_decoder"] = model.vae_decoder - if "controlnet" in components: - components_dict["controlnet"] = model.controlnet + if "Text-Encoder-Quantized" in components: + components_dict["Text-Encoder-Quantized"] = model.text_encoder + if "UNet-Quantized" in components: + components_dict["UNet-Quantized"] = model.unet + if "VAE-Decoder-Quantized" in components: + components_dict["VAE-Decoder-Quantized"] = model.vae_decoder + if "ControlNet-Quantized" in components: + components_dict["ControlNet-Quantized"] = model.controlnet # 2. Upload model assets to hub print("Uploading model assets on hub") diff --git a/qai_hub_models/models/controlnet_quantized/perf.yaml b/qai_hub_models/models/controlnet_quantized/perf.yaml index 1b8fdd4d..6c2b9e43 100644 --- a/qai_hub_models/models/controlnet_quantized/perf.yaml +++ b/qai_hub_models/models/controlnet_quantized/perf.yaml @@ -1,5 +1,5 @@ models: -- name: Text-Encoder-Quantized +- name: TextEncoder_Quantized performance_metrics: - reference_device_info: name: Samsung Galaxy S23 Ultra @@ -24,7 +24,7 @@ models: primary_compute_unit: NPU job_id: jz5w40nzg job_status: Passed -- name: VAE-Decoder-Quantized +- name: VAEDecoder_Quantized performance_metrics: - reference_device_info: name: Samsung Galaxy S23 Ultra @@ -49,7 +49,7 @@ models: primary_compute_unit: NPU job_id: jnp16kxk5 job_status: Passed -- name: UNet-Quantized +- name: UNet_Quantized performance_metrics: - reference_device_info: name: Samsung Galaxy S23 Ultra @@ -74,7 +74,7 @@ models: primary_compute_unit: NPU job_id: jmg9d7eq5 job_status: Passed -- name: ControlNet-Quantized +- name: ControlNet_Quantized performance_metrics: - reference_device_info: name: Samsung Galaxy S23 Ultra diff --git a/qai_hub_models/models/convnext_tiny/README.md b/qai_hub_models/models/convnext_tiny/README.md index 7f489f79..c7980ca4 100644 --- a/qai_hub_models/models/convnext_tiny/README.md +++ b/qai_hub_models/models/convnext_tiny/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ConvNext-Tiny can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [A ConvNet for the 2020s](https://arxiv.org/abs/2201.03545) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/convnext.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/convnext_tiny/export.py b/qai_hub_models/models/convnext_tiny/export.py index d06aadff..b2173781 100644 --- a/qai_hub_models/models/convnext_tiny/export.py +++ b/qai_hub_models/models/convnext_tiny/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "convnext_tiny" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "convnext_tiny", diff --git a/qai_hub_models/models/ddrnet23_slim/README.md b/qai_hub_models/models/ddrnet23_slim/README.md index 96da4502..ffba6e5b 100644 --- a/qai_hub_models/models/ddrnet23_slim/README.md +++ b/qai_hub_models/models/ddrnet23_slim/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of DDRNet23-Slim can be found [here](https://github.com/chenjun2hao/DDRNet.pytorch/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep Dual-resolution Networks for Real-time and Accurate Semantic Segmentation of Road Scenes](https://arxiv.org/abs/2101.06085) * [Source Model Implementation](https://github.com/chenjun2hao/DDRNet.pytorch) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ddrnet23_slim/demo.py b/qai_hub_models/models/ddrnet23_slim/demo.py index 7c0a166e..c97479cd 100644 --- a/qai_hub_models/models/ddrnet23_slim/demo.py +++ b/qai_hub_models/models/ddrnet23_slim/demo.py @@ -42,7 +42,7 @@ def main(is_test: bool = False): # Load image (_, _, height, width) = DDRNet.get_input_spec()["image"][0] orig_image = load_image(args.image) - image, _, padding = pil_resize_pad(orig_image, (height, width)) + image, scale, padding = pil_resize_pad(orig_image, (height, width)) print("Model Loaded") app = DDRNetApp(model) @@ -50,7 +50,7 @@ def main(is_test: bool = False): if not is_test: # Resize / unpad annotated image - image_annotated = pil_undo_resize_pad(output, orig_image.size, padding) + image_annotated = pil_undo_resize_pad(output, orig_image.size, scale, padding) display_or_save_image( image_annotated, args.output_dir, "ddrnet_demo_output.png" ) diff --git a/qai_hub_models/models/ddrnet23_slim/export.py b/qai_hub_models/models/ddrnet23_slim/export.py index 4141c8d6..ef4a4df7 100644 --- a/qai_hub_models/models/ddrnet23_slim/export.py +++ b/qai_hub_models/models/ddrnet23_slim/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "ddrnet23_slim" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ddrnet23_slim", diff --git a/qai_hub_models/models/deeplabv3_resnet50/README.md b/qai_hub_models/models/deeplabv3_resnet50/README.md index 8d4db7eb..d841cb3b 100644 --- a/qai_hub_models/models/deeplabv3_resnet50/README.md +++ b/qai_hub_models/models/deeplabv3_resnet50/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of DeepLabV3-ResNet50 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Rethinking Atrous Convolution for Semantic Image Segmentation](https://arxiv.org/abs/1706.05587) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/segmentation/deeplabv3.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/deeplabv3_resnet50/export.py b/qai_hub_models/models/deeplabv3_resnet50/export.py index cb49af85..2bacc87c 100644 --- a/qai_hub_models/models/deeplabv3_resnet50/export.py +++ b/qai_hub_models/models/deeplabv3_resnet50/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "deeplabv3_resnet50" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "deeplabv3_resnet50", diff --git a/qai_hub_models/models/deeplabv3_resnet50/model.py b/qai_hub_models/models/deeplabv3_resnet50/model.py index 50bd69bd..3514cc0d 100644 --- a/qai_hub_models/models/deeplabv3_resnet50/model.py +++ b/qai_hub_models/models/deeplabv3_resnet50/model.py @@ -50,8 +50,8 @@ def forward(self, image: torch.Tensor) -> torch.Tensor: """ return self.model(image)["out"] + @staticmethod def get_input_spec( - self, batch_size: int = 1, num_channels: int = 3, height: int = 224, diff --git a/qai_hub_models/models/densenet121/README.md b/qai_hub_models/models/densenet121/README.md index 5636d301..f4c9cea3 100644 --- a/qai_hub_models/models/densenet121/README.md +++ b/qai_hub_models/models/densenet121/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of DenseNet-121 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Densely Connected Convolutional Networks](https://arxiv.org/abs/1608.06993) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/densenet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/densenet121/export.py b/qai_hub_models/models/densenet121/export.py index a7b4e0ba..32e11a53 100644 --- a/qai_hub_models/models/densenet121/export.py +++ b/qai_hub_models/models/densenet121/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "densenet121" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "densenet121", diff --git a/qai_hub_models/models/detr_resnet101/README.md b/qai_hub_models/models/detr_resnet101/README.md index 7151e680..322f8a3f 100644 --- a/qai_hub_models/models/detr_resnet101/README.md +++ b/qai_hub_models/models/detr_resnet101/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of DETR-ResNet101 can be found [here](https://github.com/facebookresearch/detr/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [End-to-End Object Detection with Transformers](https://arxiv.org/abs/2005.12872) * [Source Model Implementation](https://github.com/facebookresearch/detr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/detr_resnet101/export.py b/qai_hub_models/models/detr_resnet101/export.py index 821fc3db..a3e36a66 100644 --- a/qai_hub_models/models/detr_resnet101/export.py +++ b/qai_hub_models/models/detr_resnet101/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "detr_resnet101" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "detr_resnet101", diff --git a/qai_hub_models/models/detr_resnet101_dc5/README.md b/qai_hub_models/models/detr_resnet101_dc5/README.md index bc12519e..36362aa6 100644 --- a/qai_hub_models/models/detr_resnet101_dc5/README.md +++ b/qai_hub_models/models/detr_resnet101_dc5/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of DETR-ResNet101-DC5 can be found [here](https://github.com/facebookresearch/detr/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [End-to-End Object Detection with Transformers](https://arxiv.org/abs/2005.12872) * [Source Model Implementation](https://github.com/facebookresearch/detr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/detr_resnet101_dc5/export.py b/qai_hub_models/models/detr_resnet101_dc5/export.py index d2351cef..b0b2cd5a 100644 --- a/qai_hub_models/models/detr_resnet101_dc5/export.py +++ b/qai_hub_models/models/detr_resnet101_dc5/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "detr_resnet101_dc5" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "detr_resnet101_dc5", diff --git a/qai_hub_models/models/detr_resnet50/README.md b/qai_hub_models/models/detr_resnet50/README.md index 7a9910a6..54a9d060 100644 --- a/qai_hub_models/models/detr_resnet50/README.md +++ b/qai_hub_models/models/detr_resnet50/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of DETR-ResNet50 can be found [here](https://github.com/facebookresearch/detr/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [End-to-End Object Detection with Transformers](https://arxiv.org/abs/2005.12872) * [Source Model Implementation](https://github.com/facebookresearch/detr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/detr_resnet50/export.py b/qai_hub_models/models/detr_resnet50/export.py index c2f4003e..7c6a0d6c 100644 --- a/qai_hub_models/models/detr_resnet50/export.py +++ b/qai_hub_models/models/detr_resnet50/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "detr_resnet50" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "detr_resnet50", diff --git a/qai_hub_models/models/detr_resnet50_dc5/README.md b/qai_hub_models/models/detr_resnet50_dc5/README.md index 93283e40..3d57450e 100644 --- a/qai_hub_models/models/detr_resnet50_dc5/README.md +++ b/qai_hub_models/models/detr_resnet50_dc5/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of DETR-ResNet50-DC5 can be found [here](https://github.com/facebookresearch/detr/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [End-to-End Object Detection with Transformers](https://arxiv.org/abs/2005.12872) * [Source Model Implementation](https://github.com/facebookresearch/detr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/detr_resnet50_dc5/export.py b/qai_hub_models/models/detr_resnet50_dc5/export.py index d7ee3b0f..496a68aa 100644 --- a/qai_hub_models/models/detr_resnet50_dc5/export.py +++ b/qai_hub_models/models/detr_resnet50_dc5/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "detr_resnet50_dc5" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "detr_resnet50_dc5", diff --git a/qai_hub_models/models/efficientnet_b0/README.md b/qai_hub_models/models/efficientnet_b0/README.md index 855950e7..e54cdf6b 100644 --- a/qai_hub_models/models/efficientnet_b0/README.md +++ b/qai_hub_models/models/efficientnet_b0/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of EfficientNet-B0 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks](https://arxiv.org/abs/1905.11946) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/efficientnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/efficientnet_b0/export.py b/qai_hub_models/models/efficientnet_b0/export.py index 2aaa4601..aba81864 100644 --- a/qai_hub_models/models/efficientnet_b0/export.py +++ b/qai_hub_models/models/efficientnet_b0/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "efficientnet_b0" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "efficientnet_b0", diff --git a/qai_hub_models/models/esrgan/README.md b/qai_hub_models/models/esrgan/README.md index 99d8588d..c69ed6a2 100644 --- a/qai_hub_models/models/esrgan/README.md +++ b/qai_hub_models/models/esrgan/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ESRGAN can be found [here](https://github.com/xinntao/ESRGAN/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [ESRGAN: Enhanced Super-Resolution Generative Adversarial Networks](https://arxiv.org/abs/1809.00219) * [Source Model Implementation](https://github.com/xinntao/ESRGAN/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/esrgan/export.py b/qai_hub_models/models/esrgan/export.py index ff2a383d..d82b3c60 100644 --- a/qai_hub_models/models/esrgan/export.py +++ b/qai_hub_models/models/esrgan/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "esrgan" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "esrgan", diff --git a/qai_hub_models/models/facebook_denoiser/README.md b/qai_hub_models/models/facebook_denoiser/README.md index b92ce796..5e4fbba4 100644 --- a/qai_hub_models/models/facebook_denoiser/README.md +++ b/qai_hub_models/models/facebook_denoiser/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Facebook-Denoiser can be found [here](https://github.com/facebookresearch/denoiser/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Real Time Speech Enhancement in the Waveform Domain](https://arxiv.org/abs/2006.12847) * [Source Model Implementation](https://github.com/facebookresearch/denoiser) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/facebook_denoiser/export.py b/qai_hub_models/models/facebook_denoiser/export.py index c66f846d..4f462b4f 100644 --- a/qai_hub_models/models/facebook_denoiser/export.py +++ b/qai_hub_models/models/facebook_denoiser/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -41,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -71,7 +71,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -85,7 +85,6 @@ def export_model( """ model_name = "facebook_denoiser" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "facebook_denoiser", diff --git a/qai_hub_models/models/fastsam_s/README.md b/qai_hub_models/models/fastsam_s/README.md index ef56d369..7edf6cef 100644 --- a/qai_hub_models/models/fastsam_s/README.md +++ b/qai_hub_models/models/fastsam_s/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FastSam-S can be found [here](https://github.com/CASIA-IVA-Lab/FastSAM/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Fast Segment Anything](https://arxiv.org/abs/2306.12156) * [Source Model Implementation](https://github.com/CASIA-IVA-Lab/FastSAM) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/fastsam_s/export.py b/qai_hub_models/models/fastsam_s/export.py index 4aa0ff25..61896353 100644 --- a/qai_hub_models/models/fastsam_s/export.py +++ b/qai_hub_models/models/fastsam_s/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "fastsam_s" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "fastsam_s", diff --git a/qai_hub_models/models/fastsam_x/README.md b/qai_hub_models/models/fastsam_x/README.md index 7b42289b..69da69c0 100644 --- a/qai_hub_models/models/fastsam_x/README.md +++ b/qai_hub_models/models/fastsam_x/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FastSam-X can be found [here](https://github.com/CASIA-IVA-Lab/FastSAM/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Fast Segment Anything](https://arxiv.org/abs/2306.12156) * [Source Model Implementation](https://github.com/CASIA-IVA-Lab/FastSAM) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/fastsam_x/export.py b/qai_hub_models/models/fastsam_x/export.py index 036d7cbc..c4cdf8cd 100644 --- a/qai_hub_models/models/fastsam_x/export.py +++ b/qai_hub_models/models/fastsam_x/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "fastsam_x" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "fastsam_x", diff --git a/qai_hub_models/models/fcn_resnet50/README.md b/qai_hub_models/models/fcn_resnet50/README.md index 3763ff51..df6aa7d2 100644 --- a/qai_hub_models/models/fcn_resnet50/README.md +++ b/qai_hub_models/models/fcn_resnet50/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FCN_ResNet50 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Fully Convolutional Networks for Semantic Segmentation](https://arxiv.org/abs/1411.4038) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/segmentation/fcn.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/fcn_resnet50/demo.py b/qai_hub_models/models/fcn_resnet50/demo.py index bf5ac16c..33478943 100644 --- a/qai_hub_models/models/fcn_resnet50/demo.py +++ b/qai_hub_models/models/fcn_resnet50/demo.py @@ -46,7 +46,7 @@ def main(is_test: bool = False): # load image (_, _, height, width) = FCN_ResNet50.get_input_spec()["image"][0] orig_image = load_image(args.image) - image, _, padding = pil_resize_pad(orig_image, (height, width)) + image, scale, padding = pil_resize_pad(orig_image, (height, width)) input_image = image.convert("RGB") app = FCN_ResNet50App(model) @@ -54,7 +54,7 @@ def main(is_test: bool = False): if not is_test: # Resize / unpad annotated image - image_annotated = pil_undo_resize_pad(output, orig_image.size, padding) + image_annotated = pil_undo_resize_pad(output, orig_image.size, scale, padding) display_or_save_image(image_annotated, args.output_dir, "fcn_demo_output.png") diff --git a/qai_hub_models/models/fcn_resnet50/export.py b/qai_hub_models/models/fcn_resnet50/export.py index d8d19f76..63a60381 100644 --- a/qai_hub_models/models/fcn_resnet50/export.py +++ b/qai_hub_models/models/fcn_resnet50/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "fcn_resnet50" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "fcn_resnet50", diff --git a/qai_hub_models/models/ffnet_122ns_lowres/README.md b/qai_hub_models/models/ffnet_122ns_lowres/README.md index 348254c4..2f8c8633 100644 --- a/qai_hub_models/models/ffnet_122ns_lowres/README.md +++ b/qai_hub_models/models/ffnet_122ns_lowres/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-122NS-LowRes can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_122ns_lowres/export.py b/qai_hub_models/models/ffnet_122ns_lowres/export.py index f6e6ae0d..3125277a 100644 --- a/qai_hub_models/models/ffnet_122ns_lowres/export.py +++ b/qai_hub_models/models/ffnet_122ns_lowres/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "ffnet_122ns_lowres" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_122ns_lowres", diff --git a/qai_hub_models/models/ffnet_40s/README.md b/qai_hub_models/models/ffnet_40s/README.md index 33ac664e..093da665 100644 --- a/qai_hub_models/models/ffnet_40s/README.md +++ b/qai_hub_models/models/ffnet_40s/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-40S can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_40s/export.py b/qai_hub_models/models/ffnet_40s/export.py index 22821d0e..0800da7f 100644 --- a/qai_hub_models/models/ffnet_40s/export.py +++ b/qai_hub_models/models/ffnet_40s/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "ffnet_40s" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_40s", diff --git a/qai_hub_models/models/ffnet_40s_quantized/README.md b/qai_hub_models/models/ffnet_40s_quantized/README.md index abb8c6d4..4a893a42 100644 --- a/qai_hub_models/models/ffnet_40s_quantized/README.md +++ b/qai_hub_models/models/ffnet_40s_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-40S-Quantized can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_40s_quantized/export.py b/qai_hub_models/models/ffnet_40s_quantized/export.py index ff0c2abc..a12d147c 100644 --- a/qai_hub_models/models/ffnet_40s_quantized/export.py +++ b/qai_hub_models/models/ffnet_40s_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.ffnet_40s_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "ffnet_40s_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_40s_quantized", diff --git a/qai_hub_models/models/ffnet_54s/README.md b/qai_hub_models/models/ffnet_54s/README.md index 81639336..1e99c724 100644 --- a/qai_hub_models/models/ffnet_54s/README.md +++ b/qai_hub_models/models/ffnet_54s/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-54S can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_54s/export.py b/qai_hub_models/models/ffnet_54s/export.py index 7b9c3524..14761dc7 100644 --- a/qai_hub_models/models/ffnet_54s/export.py +++ b/qai_hub_models/models/ffnet_54s/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "ffnet_54s" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_54s", diff --git a/qai_hub_models/models/ffnet_54s_quantized/README.md b/qai_hub_models/models/ffnet_54s_quantized/README.md index d978a2e7..011b5076 100644 --- a/qai_hub_models/models/ffnet_54s_quantized/README.md +++ b/qai_hub_models/models/ffnet_54s_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-54S-Quantized can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_54s_quantized/export.py b/qai_hub_models/models/ffnet_54s_quantized/export.py index e759e283..382d06b3 100644 --- a/qai_hub_models/models/ffnet_54s_quantized/export.py +++ b/qai_hub_models/models/ffnet_54s_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.ffnet_54s_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "ffnet_54s_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_54s_quantized", diff --git a/qai_hub_models/models/ffnet_78s/README.md b/qai_hub_models/models/ffnet_78s/README.md index 016fde5d..641971d7 100644 --- a/qai_hub_models/models/ffnet_78s/README.md +++ b/qai_hub_models/models/ffnet_78s/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-78S can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_78s/export.py b/qai_hub_models/models/ffnet_78s/export.py index 01c22165..9242f6bb 100644 --- a/qai_hub_models/models/ffnet_78s/export.py +++ b/qai_hub_models/models/ffnet_78s/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "ffnet_78s" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_78s", diff --git a/qai_hub_models/models/ffnet_78s_lowres/README.md b/qai_hub_models/models/ffnet_78s_lowres/README.md index 5b8d5e2d..2708b7d3 100644 --- a/qai_hub_models/models/ffnet_78s_lowres/README.md +++ b/qai_hub_models/models/ffnet_78s_lowres/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-78S-LowRes can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_78s_lowres/export.py b/qai_hub_models/models/ffnet_78s_lowres/export.py index 78c0431d..00e1a3b1 100644 --- a/qai_hub_models/models/ffnet_78s_lowres/export.py +++ b/qai_hub_models/models/ffnet_78s_lowres/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "ffnet_78s_lowres" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_78s_lowres", diff --git a/qai_hub_models/models/ffnet_78s_quantized/README.md b/qai_hub_models/models/ffnet_78s_quantized/README.md index 74185134..cad29c31 100644 --- a/qai_hub_models/models/ffnet_78s_quantized/README.md +++ b/qai_hub_models/models/ffnet_78s_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of FFNet-78S-Quantized can be found [here](https://github.com/Qualcomm-AI-research/FFNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Simple and Efficient Architectures for Semantic Segmentation](https://arxiv.org/abs/2206.08236) * [Source Model Implementation](https://github.com/Qualcomm-AI-research/FFNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/ffnet_78s_quantized/export.py b/qai_hub_models/models/ffnet_78s_quantized/export.py index 6bd05626..0e2f3a1e 100644 --- a/qai_hub_models/models/ffnet_78s_quantized/export.py +++ b/qai_hub_models/models/ffnet_78s_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.ffnet_78s_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "ffnet_78s_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "ffnet_78s_quantized", diff --git a/qai_hub_models/models/googlenet/README.md b/qai_hub_models/models/googlenet/README.md index 3ceaaa5a..f3517617 100644 --- a/qai_hub_models/models/googlenet/README.md +++ b/qai_hub_models/models/googlenet/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of GoogLeNet can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Going Deeper with Convolutions](https://arxiv.org/abs/1409.4842) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/googlenet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/googlenet/export.py b/qai_hub_models/models/googlenet/export.py index 42660252..38a7d779 100644 --- a/qai_hub_models/models/googlenet/export.py +++ b/qai_hub_models/models/googlenet/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "googlenet" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "googlenet", diff --git a/qai_hub_models/models/googlenet_quantized/README.md b/qai_hub_models/models/googlenet_quantized/README.md index fd3b845b..371c3c5d 100644 --- a/qai_hub_models/models/googlenet_quantized/README.md +++ b/qai_hub_models/models/googlenet_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of GoogLeNetQuantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Going Deeper with Convolutions](https://arxiv.org/abs/1409.4842) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/googlenet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/googlenet_quantized/export.py b/qai_hub_models/models/googlenet_quantized/export.py index cf2be9a3..34cc8ec6 100644 --- a/qai_hub_models/models/googlenet_quantized/export.py +++ b/qai_hub_models/models/googlenet_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.googlenet_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "googlenet_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "googlenet_quantized", @@ -181,7 +179,9 @@ def export_model( torch_out = torch_inference(model, sample_inputs) assert inference_job.wait().success inference_result = inference_job.download_output_data() - print_inference_metrics(inference_job, inference_result, torch_out) + print_inference_metrics( + inference_job, inference_result, torch_out, metrics="psnr,top1,top5" + ) print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) diff --git a/qai_hub_models/models/hrnet_pose/README.md b/qai_hub_models/models/hrnet_pose/README.md index bae7d57c..b9e40786 100644 --- a/qai_hub_models/models/hrnet_pose/README.md +++ b/qai_hub_models/models/hrnet_pose/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of HRNetPose can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep High-Resolution Representation Learning for Human Pose Estimation](https://arxiv.org/abs/1902.09212) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/hrnet_posenet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/hrnet_pose/export.py b/qai_hub_models/models/hrnet_pose/export.py index ffb8c70f..2c4d9846 100644 --- a/qai_hub_models/models/hrnet_pose/export.py +++ b/qai_hub_models/models/hrnet_pose/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "hrnet_pose" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "hrnet_pose", diff --git a/qai_hub_models/models/hrnet_pose_quantized/README.md b/qai_hub_models/models/hrnet_pose_quantized/README.md index b6f64114..7e4593b3 100644 --- a/qai_hub_models/models/hrnet_pose_quantized/README.md +++ b/qai_hub_models/models/hrnet_pose_quantized/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of HRNetPoseQuantized can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep High-Resolution Representation Learning for Human Pose Estimation](https://arxiv.org/abs/1902.09212) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/hrnet_posenet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/hrnet_pose_quantized/export.py b/qai_hub_models/models/hrnet_pose_quantized/export.py index cce76951..f65c3644 100644 --- a/qai_hub_models/models/hrnet_pose_quantized/export.py +++ b/qai_hub_models/models/hrnet_pose_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.hrnet_pose_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -44,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +87,6 @@ def export_model( """ model_name = "hrnet_pose_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "hrnet_pose_quantized", diff --git a/qai_hub_models/models/hrnet_pose_quantized/model.py b/qai_hub_models/models/hrnet_pose_quantized/model.py index 957ecff1..00191c59 100644 --- a/qai_hub_models/models/hrnet_pose_quantized/model.py +++ b/qai_hub_models/models/hrnet_pose_quantized/model.py @@ -4,6 +4,14 @@ # --------------------------------------------------------------------- from __future__ import annotations +# isort: off +# This verifies aimet is installed, and this must be included first. +from qai_hub_models.utils.quantization_aimet import ( + AIMETQuantizableMixin, +) + +# isort: on + import torch from aimet_torch.cross_layer_equalization import equalize_model from aimet_torch.quantsim import QuantizationSimModel, load_encodings_to_sim @@ -11,12 +19,6 @@ from qai_hub_models.models.hrnet_pose.model import HRNetPose from qai_hub_models.utils.asset_loaders import CachedWebModelAsset -# This verifies aimet is installed, and this must be included first. -from qai_hub_models.utils.quantization_aimet import ( # isort: skip - AIMETQuantizableMixin, -) - - MODEL_ID = __name__.split(".")[-2] MODEL_ASSET_VERSION = 1 # Weights and config stored in S3 are sourced from diff --git a/qai_hub_models/models/huggingface_wavlm_base_plus/README.md b/qai_hub_models/models/huggingface_wavlm_base_plus/README.md index 170ac687..047a8024 100644 --- a/qai_hub_models/models/huggingface_wavlm_base_plus/README.md +++ b/qai_hub_models/models/huggingface_wavlm_base_plus/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of HuggingFace-WavLM-Base-Plus can be found [here](https://github.com/microsoft/unilm/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing](https://arxiv.org/abs/2110.13900) * [Source Model Implementation](https://huggingface.co/patrickvonplaten/wavlm-libri-clean-100h-base-plus/tree/main) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/huggingface_wavlm_base_plus/export.py b/qai_hub_models/models/huggingface_wavlm_base_plus/export.py index a21bb9c9..66e9f8b7 100644 --- a/qai_hub_models/models/huggingface_wavlm_base_plus/export.py +++ b/qai_hub_models/models/huggingface_wavlm_base_plus/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -41,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -71,7 +71,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -85,7 +85,6 @@ def export_model( """ model_name = "huggingface_wavlm_base_plus" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "huggingface_wavlm_base_plus", diff --git a/qai_hub_models/models/inception_v3/README.md b/qai_hub_models/models/inception_v3/README.md index af6c9e68..a70d3589 100644 --- a/qai_hub_models/models/inception_v3/README.md +++ b/qai_hub_models/models/inception_v3/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Inception-v3 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Rethinking the Inception Architecture for Computer Vision](http://arxiv.org/abs/1512.00567) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/inception.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/inception_v3/export.py b/qai_hub_models/models/inception_v3/export.py index e9f2ff1b..f722ee3a 100644 --- a/qai_hub_models/models/inception_v3/export.py +++ b/qai_hub_models/models/inception_v3/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "inception_v3" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "inception_v3", diff --git a/qai_hub_models/models/inception_v3_quantized/README.md b/qai_hub_models/models/inception_v3_quantized/README.md index 6198c751..4cd5430b 100644 --- a/qai_hub_models/models/inception_v3_quantized/README.md +++ b/qai_hub_models/models/inception_v3_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Inception-v3Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Rethinking the Inception Architecture for Computer Vision](http://arxiv.org/abs/1512.00567) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/inception.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/inception_v3_quantized/export.py b/qai_hub_models/models/inception_v3_quantized/export.py index 569e757c..816369ff 100644 --- a/qai_hub_models/models/inception_v3_quantized/export.py +++ b/qai_hub_models/models/inception_v3_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.inception_v3_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "inception_v3_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "inception_v3_quantized", @@ -181,7 +179,9 @@ def export_model( torch_out = torch_inference(model, sample_inputs) assert inference_job.wait().success inference_result = inference_job.download_output_data() - print_inference_metrics(inference_job, inference_result, torch_out) + print_inference_metrics( + inference_job, inference_result, torch_out, metrics="psnr,top1,top5" + ) print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) diff --git a/qai_hub_models/models/inception_v3_quantized/model.py b/qai_hub_models/models/inception_v3_quantized/model.py index ef630f60..cb320154 100644 --- a/qai_hub_models/models/inception_v3_quantized/model.py +++ b/qai_hub_models/models/inception_v3_quantized/model.py @@ -8,6 +8,7 @@ # This verifies aimet is installed, and this must be included first. from qai_hub_models.utils.quantization_aimet import ( AIMETQuantizableMixin, + HubCompileOptionsInt8Mixin, ) # isort: on @@ -25,7 +26,9 @@ DEFAULT_ENCODINGS = "inception_v3_quantized_encodings.json" -class InceptionNetV3Quantizable(AIMETQuantizableMixin, InceptionNetV3): +class InceptionNetV3Quantizable( + HubCompileOptionsInt8Mixin, AIMETQuantizableMixin, InceptionNetV3 +): """InceptionNetV3 with post train quantization support. Supports only 8 bit weights and activations, and only loads pre-quantized checkpoints. diff --git a/qai_hub_models/models/inception_v3_quantized/perf.yaml b/qai_hub_models/models/inception_v3_quantized/perf.yaml index 5d7edfbb..ec2936b4 100644 --- a/qai_hub_models/models/inception_v3_quantized/perf.yaml +++ b/qai_hub_models/models/inception_v3_quantized/perf.yaml @@ -28,19 +28,19 @@ models: - name: Inception-v3Quantized performance_metrics: - torchscript_onnx_tflite: - inference_time: 1772.0 - throughput: 564.3340857787811 + inference_time: 755.0 + throughput: 1324.5033112582782 estimated_peak_memory_range: - min: 28672 - max: 2456712 + min: 12288 + max: 1825256 primary_compute_unit: NPU precision: fp16 layer_info: - layers_on_npu: 394 + layers_on_npu: 150 layers_on_gpu: 0 layers_on_cpu: 0 - total_layers: 394 - job_id: jep2r9jxg + total_layers: 150 + job_id: jygzlmjo5 job_status: Passed torchscript_onnx_qnn: inference_time: 'null' @@ -64,4 +64,4 @@ models: os_name: Android manufacturer: Samsung chipset: Snapdragon® 8 Gen 2 - timestamp: '2024-02-21T16:37:27.025184Z' + timestamp: '2024-02-23T04:42:57.781769Z' diff --git a/qai_hub_models/models/lama_dilated/README.md b/qai_hub_models/models/lama_dilated/README.md index 28f6ea2e..3c9410ff 100644 --- a/qai_hub_models/models/lama_dilated/README.md +++ b/qai_hub_models/models/lama_dilated/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of LaMa-Dilated can be found [here](https://github.com/advimman/lama/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Resolution-robust Large Mask Inpainting with Fourier Convolutions](https://arxiv.org/abs/2109.07161) * [Source Model Implementation](https://github.com/advimman/lama) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/lama_dilated/export.py b/qai_hub_models/models/lama_dilated/export.py index 488b05f1..387f5e9c 100644 --- a/qai_hub_models/models/lama_dilated/export.py +++ b/qai_hub_models/models/lama_dilated/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "lama_dilated" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "lama_dilated", diff --git a/qai_hub_models/models/litehrnet/README.md b/qai_hub_models/models/litehrnet/README.md index fe566187..76e46a9f 100644 --- a/qai_hub_models/models/litehrnet/README.md +++ b/qai_hub_models/models/litehrnet/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of LiteHRNet can be found [here](https://github.com/HRNet/Lite-HRNet/blob/hrnet/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Lite-HRNet: A Lightweight High-Resolution Network](https://arxiv.org/abs/2104.06403) * [Source Model Implementation](https://github.com/HRNet/Lite-HRNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/litehrnet/export.py b/qai_hub_models/models/litehrnet/export.py index 5e45b9d7..b163c9d0 100644 --- a/qai_hub_models/models/litehrnet/export.py +++ b/qai_hub_models/models/litehrnet/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -42,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -72,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -86,7 +86,6 @@ def export_model( """ model_name = "litehrnet" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "litehrnet", diff --git a/qai_hub_models/models/llama_v2_7b_chat_quantized/README.md b/qai_hub_models/models/llama_v2_7b_chat_quantized/README.md new file mode 100644 index 00000000..85ea8573 --- /dev/null +++ b/qai_hub_models/models/llama_v2_7b_chat_quantized/README.md @@ -0,0 +1,31 @@ +[![Qualcomm® AI Hub Models](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/quic-logo.jpg)](../../README.md) + + +# [Llama-v2-7B-Chat: State-of-the-art large language model useful on a variety of language understanding and generation tasks](https://aihub.qualcomm.com/models/llama_v2_7b_chat_quantized) + +Llama 2 is a family of LLMs. The "Chat" at the end indicates that the model is optimized for chatbot-like dialogue. The model is quantized to 4-bit weights and 16-bit activations making it suitable for on-device deployment. For Prompt and output length specified below, the time to first token is Llama-PromptProcessor-Quantized's latency and average time per addition token is Llama-TokenGenerator-KVCache-Quantized's latency. + +This is based on the implementation of Llama-v2-7B-Chat found +[here](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf). This repository contains scripts for optimized on-device +export suitable to run on Qualcomm® devices. More details on model performance +accross various devices, can be found [here](https://aihub.qualcomm.com/models/llama_v2_7b_chat_quantized). + +[Sign up](https://aihub.qualcomm.com/) for early access to run these models on +a hosted Qualcomm® device. + + + +## License +- The license for the original implementation of Llama-v2-7B-Chat can be found + [here](https://github.com/facebookresearch/llama/blob/main/LICENSE). +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). + +## References +* [LLaMA: Open and Efficient Foundation Language Models](https://arxiv.org/abs/2302.13971) +* [Source Model Implementation](https://huggingface.co/meta-llama/Llama-2-7b-chat-hf) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/llama_v2_7b_chat_quantized/info.yaml b/qai_hub_models/models/llama_v2_7b_chat_quantized/info.yaml new file mode 100644 index 00000000..584f2f8b --- /dev/null +++ b/qai_hub_models/models/llama_v2_7b_chat_quantized/info.yaml @@ -0,0 +1,46 @@ +name: Llama-v2-7B-Chat +id: llama_v2_7b_chat_quantized +status: public # Renable when approved by marketing #9577 +headline: State-of-the-art large language model useful on a variety of language + understanding and generation tasks. +domain: Generative AI +description: Llama 2 is a family of LLMs. The "Chat" at the end indicates that + the model is optimized for chatbot-like dialogue. The model is quantized to + 4-bit weights and 16-bit activations making it suitable for on-device + deployment. For Prompt and output length specified below, the time to first token is + Llama-PromptProcessor-Quantized's latency and average time per addition token is + Llama-TokenGenerator-KVCache-Quantized's latency. +use_case: Text Generation +tags: + - llm + - generative-ai + - quantized +research_paper: https://arxiv.org/abs/2302.13971 +research_paper_title: "LLaMA: Open and Efficient Foundation Language Models" +license: https://github.com/facebookresearch/llama/blob/main/LICENSE +source_repo: https://huggingface.co/meta-llama/Llama-2-7b-chat-hf +technical_details: + Number of parameters: 7B + Model size: 3.6GB + Model-1 (Prompt Processor): Llama-PromptProcessor-Quantized + Max context length: 1024 + Prompt processor input: 1024 tokens + Prompt processor output: 1 output token + KVCache for token generator + Model-2 (Token Generator): Llama-TokenGenerator-KVCache-Quantized + Token generator input: 1 input token + past KVCache + Token generator output: 1 output token + KVCache for next iteration + Decoding length: 1024 (1 output token + 1023 from KVCache) + Use: Initiate conversation with prompt-processor and then token generator for subsequent iterations. + QNN-SDK: "2.19" +applicable_scenarios: + - Dialogue + - Content Generation + - Customer Support +related_models: [] +form_factors: + - Phone + - Tablet +has_static_banner: yes +has_animated_banner: yes +license_type: llama2 +dataset: [] diff --git a/qai_hub_models/models/llama_v2_7b_chat_quantized/perf.yaml b/qai_hub_models/models/llama_v2_7b_chat_quantized/perf.yaml new file mode 100644 index 00000000..705e6aab --- /dev/null +++ b/qai_hub_models/models/llama_v2_7b_chat_quantized/perf.yaml @@ -0,0 +1,77 @@ +models: +- name: Llama-TokenGenerator-KVCache-Quantized + performance_metrics: + - reference_device_info: + name: Samsung Galaxy S23 Ultra + os: '13' + form_factor: Phone + os_name: Android + manufacturer: Samsung + chipset: Snapdragon® 8 Gen 2 + timestamp: '2024-01-26T00:34:02.549319Z' + torchscript_onnx_qnn: + inference_time: 117812 + throughput: 8.48 + estimated_peak_memory_range: + min: 69697536 + max: 249894184 + layer_info: + layers_on_npu: 34841 + layers_on_gpu: 0 + layers_on_cpu: 0 + total_layers: 34841 + precision: uint16 + primary_compute_unit: NPU + job_id: "null" + job_status: Passed +- name: Llama-PromptProcessor-Quantized + performance_metrics: + - reference_device_info: + name: Samsung Galaxy S23 Ultra + os: '13' + form_factor: Phone + os_name: Android + manufacturer: Samsung + chipset: Snapdragon® 8 Gen 2 + timestamp: '2024-01-26T00:34:02.549319Z' + torchscript_onnx_qnn: + inference_time: 2578521 + throughput: 0.38 + estimated_peak_memory_range: + min: 12124160 + max: 17599768 + layer_info: + layers_on_npu: 31769 + layers_on_gpu: 0 + layers_on_cpu: 0 + total_layers: 31769 + precision: uint16 + primary_compute_unit: NPU + job_id: "null" + job_status: Passed +aggregated: + supported_devices: + - Samsung Galaxy S23 Ultra + supported_oses: + - Android + supported_chipsets: + - Snapdragon® 8 Gen 2 + performance_metrics: + - reference_device_info: + name: Samsung Galaxy S23 Ultra + os: '13' + form_factor: Phone + os_name: Android + manufacturer: Samsung + chipset: Snapdragon® 8 Gen 2 + timestamp: '2024-01-26T00:34:02.549319Z' + torchscript_onnx_qnn: + inference_time: 117423.0 + throughput: 8.5 + estimated_peak_memory_range: + min: 68579328 + max: 73044264 + precision: uint16 + primary_compute_unit: NPU + job_id: "" + job_status: Passed diff --git a/qai_hub_models/models/mediapipe_face/README.md b/qai_hub_models/models/mediapipe_face/README.md index 01c85c99..9cc061b7 100644 --- a/qai_hub_models/models/mediapipe_face/README.md +++ b/qai_hub_models/models/mediapipe_face/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MediaPipe-Face-Detection can be found [here](https://github.com/zmurez/MediaPipePyTorch/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [BlazeFace: Sub-millisecond Neural Face Detection on Mobile GPUs](https://arxiv.org/abs/1907.05047) * [Source Model Implementation](https://github.com/zmurez/MediaPipePyTorch/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mediapipe_face/export.py b/qai_hub_models/models/mediapipe_face/export.py index 59733441..c7f32d04 100644 --- a/qai_hub_models/models/mediapipe_face/export.py +++ b/qai_hub_models/models/mediapipe_face/export.py @@ -16,11 +16,8 @@ import torch from qai_hub_models.models.mediapipe_face import Model -from qai_hub_models.utils.args import ( - export_parser, - get_model_kwargs, - parse_target_runtime, -) +from qai_hub_models.utils.args import export_parser, get_model_kwargs +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -77,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -91,7 +88,6 @@ def export_model( """ model_name = "mediapipe_face" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) component_arg = components components = components or ALL_COMPONENTS for component in components: diff --git a/qai_hub_models/models/mediapipe_hand/README.md b/qai_hub_models/models/mediapipe_hand/README.md index 7ad1da5e..09fae2c0 100644 --- a/qai_hub_models/models/mediapipe_hand/README.md +++ b/qai_hub_models/models/mediapipe_hand/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MediaPipe-Hand-Detection can be found [here](https://github.com/zmurez/MediaPipePyTorch/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [MediaPipe Hands: On-device Real-time Hand Tracking](https://arxiv.org/abs/2006.10214) * [Source Model Implementation](https://github.com/zmurez/MediaPipePyTorch/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mediapipe_hand/export.py b/qai_hub_models/models/mediapipe_hand/export.py index 8d8cae99..7d92ac14 100644 --- a/qai_hub_models/models/mediapipe_hand/export.py +++ b/qai_hub_models/models/mediapipe_hand/export.py @@ -16,11 +16,8 @@ import torch from qai_hub_models.models.mediapipe_hand import Model -from qai_hub_models.utils.args import ( - export_parser, - get_model_kwargs, - parse_target_runtime, -) +from qai_hub_models.utils.args import export_parser, get_model_kwargs +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -77,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -91,7 +88,6 @@ def export_model( """ model_name = "mediapipe_hand" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) component_arg = components components = components or ALL_COMPONENTS for component in components: diff --git a/qai_hub_models/models/mediapipe_pose/README.md b/qai_hub_models/models/mediapipe_pose/README.md index 19eb21a0..1c01b256 100644 --- a/qai_hub_models/models/mediapipe_pose/README.md +++ b/qai_hub_models/models/mediapipe_pose/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MediaPipe-Pose-Estimation can be found [here](https://github.com/zmurez/MediaPipePyTorch/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [BlazePose: On-device Real-time Body Pose tracking](https://arxiv.org/abs/2006.10204) * [Source Model Implementation](https://github.com/zmurez/MediaPipePyTorch/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mediapipe_pose/export.py b/qai_hub_models/models/mediapipe_pose/export.py index 4a363c31..9d2b78aa 100644 --- a/qai_hub_models/models/mediapipe_pose/export.py +++ b/qai_hub_models/models/mediapipe_pose/export.py @@ -16,11 +16,8 @@ import torch from qai_hub_models.models.mediapipe_pose import Model -from qai_hub_models.utils.args import ( - export_parser, - get_model_kwargs, - parse_target_runtime, -) +from qai_hub_models.utils.args import export_parser, get_model_kwargs +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -77,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -91,7 +88,6 @@ def export_model( """ model_name = "mediapipe_pose" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) component_arg = components components = components or ALL_COMPONENTS for component in components: diff --git a/qai_hub_models/models/mediapipe_selfie/README.md b/qai_hub_models/models/mediapipe_selfie/README.md index 70de5777..e9a1ce15 100644 --- a/qai_hub_models/models/mediapipe_selfie/README.md +++ b/qai_hub_models/models/mediapipe_selfie/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MediaPipe-Selfie-Segmentation can be found [here](https://github.com/google/mediapipe/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Image segmentation guide](https://developers.google.com/mediapipe/solutions/vision/image_segmenter/) * [Source Model Implementation](https://github.com/google/mediapipe/tree/master/mediapipe/modules/selfie_segmentation) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mediapipe_selfie/export.py b/qai_hub_models/models/mediapipe_selfie/export.py index a4bdd82f..b422b5e5 100644 --- a/qai_hub_models/models/mediapipe_selfie/export.py +++ b/qai_hub_models/models/mediapipe_selfie/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "mediapipe_selfie" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "mediapipe_selfie", diff --git a/qai_hub_models/models/mnasnet05/README.md b/qai_hub_models/models/mnasnet05/README.md index 0db50a4c..3470b5ee 100644 --- a/qai_hub_models/models/mnasnet05/README.md +++ b/qai_hub_models/models/mnasnet05/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MNASNet05 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [MnasNet: Platform-Aware Neural Architecture Search for Mobile](https://arxiv.org/abs/1807.11626) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/mnasnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mnasnet05/export.py b/qai_hub_models/models/mnasnet05/export.py index 48bc5bfe..670aaac1 100644 --- a/qai_hub_models/models/mnasnet05/export.py +++ b/qai_hub_models/models/mnasnet05/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "mnasnet05" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "mnasnet05", diff --git a/qai_hub_models/models/mobilenet_v2/README.md b/qai_hub_models/models/mobilenet_v2/README.md index a207207f..f23506ad 100644 --- a/qai_hub_models/models/mobilenet_v2/README.md +++ b/qai_hub_models/models/mobilenet_v2/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MobileNet-v2 can be found [here](https://github.com/tonylins/pytorch-mobilenet-v2/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [MobileNetV2: Inverted Residuals and Linear Bottlenecks](https://arxiv.org/abs/1801.04381) * [Source Model Implementation](https://github.com/tonylins/pytorch-mobilenet-v2/tree/master) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mobilenet_v2/export.py b/qai_hub_models/models/mobilenet_v2/export.py index c3eda9f4..c9c07912 100644 --- a/qai_hub_models/models/mobilenet_v2/export.py +++ b/qai_hub_models/models/mobilenet_v2/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "mobilenet_v2" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "mobilenet_v2", diff --git a/qai_hub_models/models/mobilenet_v2_quantized/README.md b/qai_hub_models/models/mobilenet_v2_quantized/README.md index b95cd4f0..da359dcd 100644 --- a/qai_hub_models/models/mobilenet_v2_quantized/README.md +++ b/qai_hub_models/models/mobilenet_v2_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MobileNet-v2-Quantized can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [MobileNetV2: Inverted Residuals and Linear Bottlenecks](https://arxiv.org/abs/1801.04381) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/mobilenetv2) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mobilenet_v2_quantized/export.py b/qai_hub_models/models/mobilenet_v2_quantized/export.py index 08b14483..63655d62 100644 --- a/qai_hub_models/models/mobilenet_v2_quantized/export.py +++ b/qai_hub_models/models/mobilenet_v2_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.mobilenet_v2_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "mobilenet_v2_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "mobilenet_v2_quantized", @@ -181,7 +179,9 @@ def export_model( torch_out = torch_inference(model, sample_inputs) assert inference_job.wait().success inference_result = inference_job.download_output_data() - print_inference_metrics(inference_job, inference_result, torch_out) + print_inference_metrics( + inference_job, inference_result, torch_out, metrics="psnr,top1,top5" + ) print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) @@ -190,7 +190,7 @@ def export_model( def main(): warnings.filterwarnings("ignore") - parser = export_parser(model_cls=Model, supports_qnn=False) + parser = export_parser(model_cls=Model) args = parser.parse_args() export_model(**vars(args)) diff --git a/qai_hub_models/models/mobilenet_v2_quantized/model.py b/qai_hub_models/models/mobilenet_v2_quantized/model.py index 8ab961bb..5c922ffe 100644 --- a/qai_hub_models/models/mobilenet_v2_quantized/model.py +++ b/qai_hub_models/models/mobilenet_v2_quantized/model.py @@ -8,6 +8,7 @@ # This verifies aimet is installed, and this must be included first. from qai_hub_models.utils.quantization_aimet import ( AIMETQuantizableMixin, + HubCompileOptionsInt8Mixin, ) # isort: on @@ -32,7 +33,9 @@ DEFAULT_ENCODINGS = "encodings.json" -class MobileNetV2Quantizable(AIMETQuantizableMixin, MobileNetV2): +class MobileNetV2Quantizable( + HubCompileOptionsInt8Mixin, AIMETQuantizableMixin, MobileNetV2 +): """MobileNetV2 with post train quantization support.""" def __init__( @@ -102,13 +105,3 @@ def from_pretrained( sim.model.eval() return cls(sim) - - def get_hub_compile_options( - self, - target_runtime: TargetRuntime, - other_compile_options: str = "", - ) -> str: - compile_options = super().get_hub_compile_options( - target_runtime, other_compile_options - ) - return compile_options + " --quantize_full_type int8 --quantize_io" diff --git a/qai_hub_models/models/mobilenet_v3_large/README.md b/qai_hub_models/models/mobilenet_v3_large/README.md index 130a4e3c..5a10f6e8 100644 --- a/qai_hub_models/models/mobilenet_v3_large/README.md +++ b/qai_hub_models/models/mobilenet_v3_large/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MobileNet-v3-Large can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Searching for MobileNetV3](https://arxiv.org/abs/1905.02244) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/mobilenetv3.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mobilenet_v3_large/export.py b/qai_hub_models/models/mobilenet_v3_large/export.py index 4e364b1d..50da73da 100644 --- a/qai_hub_models/models/mobilenet_v3_large/export.py +++ b/qai_hub_models/models/mobilenet_v3_large/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "mobilenet_v3_large" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "mobilenet_v3_large", diff --git a/qai_hub_models/models/mobilenet_v3_small/README.md b/qai_hub_models/models/mobilenet_v3_small/README.md index f11cb04d..2fc1c243 100644 --- a/qai_hub_models/models/mobilenet_v3_small/README.md +++ b/qai_hub_models/models/mobilenet_v3_small/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of MobileNet-v3-Small can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Searching for MobileNetV3](https://arxiv.org/abs/1905.02244) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/mobilenetv3.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/mobilenet_v3_small/export.py b/qai_hub_models/models/mobilenet_v3_small/export.py index efbf745e..26c8f0f1 100644 --- a/qai_hub_models/models/mobilenet_v3_small/export.py +++ b/qai_hub_models/models/mobilenet_v3_small/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "mobilenet_v3_small" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "mobilenet_v3_small", diff --git a/qai_hub_models/models/openai_clip/README.md b/qai_hub_models/models/openai_clip/README.md index a334800c..91a81680 100644 --- a/qai_hub_models/models/openai_clip/README.md +++ b/qai_hub_models/models/openai_clip/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of OpenAI-Clip can be found [here](https://github.com/openai/CLIP/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Learning Transferable Visual Models From Natural Language Supervision](https://arxiv.org/abs/2103.00020) * [Source Model Implementation](https://github.com/openai/CLIP/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/openai_clip/export.py b/qai_hub_models/models/openai_clip/export.py index 54990d0b..d8d60fc1 100644 --- a/qai_hub_models/models/openai_clip/export.py +++ b/qai_hub_models/models/openai_clip/export.py @@ -16,11 +16,8 @@ import torch from qai_hub_models.models.openai_clip import Model -from qai_hub_models.utils.args import ( - export_parser, - get_model_kwargs, - parse_target_runtime, -) +from qai_hub_models.utils.args import export_parser, get_model_kwargs +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -77,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -91,7 +88,6 @@ def export_model( """ model_name = "openai_clip" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) component_arg = components components = components or ALL_COMPONENTS for component in components: diff --git a/qai_hub_models/models/openpose/README.md b/qai_hub_models/models/openpose/README.md index 1ae81491..5614acf9 100644 --- a/qai_hub_models/models/openpose/README.md +++ b/qai_hub_models/models/openpose/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of OpenPose can be found [here](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [OpenPose: Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields](https://arxiv.org/abs/1812.08008) * [Source Model Implementation](https://github.com/CMU-Perceptual-Computing-Lab/openpose) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/openpose/export.py b/qai_hub_models/models/openpose/export.py index 8f29e78f..bb86fa55 100644 --- a/qai_hub_models/models/openpose/export.py +++ b/qai_hub_models/models/openpose/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "openpose" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "openpose", diff --git a/qai_hub_models/models/quicksrnetlarge/README.md b/qai_hub_models/models/quicksrnetlarge/README.md index 31d3723e..c3153d55 100644 --- a/qai_hub_models/models/quicksrnetlarge/README.md +++ b/qai_hub_models/models/quicksrnetlarge/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of QuickSRNetLarge can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [QuickSRNet: Plain Single-Image Super-Resolution Architecture for Faster Inference on Mobile Platforms](https://arxiv.org/abs/2303.04336) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/quicksrnet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/quicksrnetlarge/export.py b/qai_hub_models/models/quicksrnetlarge/export.py index d6e2239f..07628b5b 100644 --- a/qai_hub_models/models/quicksrnetlarge/export.py +++ b/qai_hub_models/models/quicksrnetlarge/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "quicksrnetlarge" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "quicksrnetlarge", diff --git a/qai_hub_models/models/quicksrnetmedium/README.md b/qai_hub_models/models/quicksrnetmedium/README.md index 0c2a24e4..436d148a 100644 --- a/qai_hub_models/models/quicksrnetmedium/README.md +++ b/qai_hub_models/models/quicksrnetmedium/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of QuickSRNetMedium can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [QuickSRNet: Plain Single-Image Super-Resolution Architecture for Faster Inference on Mobile Platforms](https://arxiv.org/abs/2303.04336) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/quicksrnet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/quicksrnetmedium/export.py b/qai_hub_models/models/quicksrnetmedium/export.py index 978d5e70..9c9cde02 100644 --- a/qai_hub_models/models/quicksrnetmedium/export.py +++ b/qai_hub_models/models/quicksrnetmedium/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "quicksrnetmedium" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "quicksrnetmedium", diff --git a/qai_hub_models/models/quicksrnetsmall/README.md b/qai_hub_models/models/quicksrnetsmall/README.md index 4cf6e004..4d1cf350 100644 --- a/qai_hub_models/models/quicksrnetsmall/README.md +++ b/qai_hub_models/models/quicksrnetsmall/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of QuickSRNetSmall can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [QuickSRNet: Plain Single-Image Super-Resolution Architecture for Faster Inference on Mobile Platforms](https://arxiv.org/abs/2303.04336) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/quicksrnet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/quicksrnetsmall/export.py b/qai_hub_models/models/quicksrnetsmall/export.py index 080fc777..35428879 100644 --- a/qai_hub_models/models/quicksrnetsmall/export.py +++ b/qai_hub_models/models/quicksrnetsmall/export.py @@ -20,12 +20,13 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( print_inference_metrics, + print_on_target_demo_cmd, print_profile_metrics_from_job, ) from qai_hub_models.utils.qai_hub_helpers import ( @@ -43,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +88,6 @@ def export_model( """ model_name = "quicksrnetsmall" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "quicksrnetsmall", @@ -180,6 +180,8 @@ def export_model( ) print_inference_metrics(inference_job, inference_result, torch_out) + print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) + return (compile_job, profile_job, inference_job) diff --git a/qai_hub_models/models/real_esrgan_general_x4v3/README.md b/qai_hub_models/models/real_esrgan_general_x4v3/README.md index 5729860d..f6da96de 100644 --- a/qai_hub_models/models/real_esrgan_general_x4v3/README.md +++ b/qai_hub_models/models/real_esrgan_general_x4v3/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Real-ESRGAN-General-x4v3 can be found [here](https://github.com/xinntao/Real-ESRGAN/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data](https://arxiv.org/abs/2107.10833) * [Source Model Implementation](https://github.com/xinntao/Real-ESRGAN/tree/master) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/real_esrgan_general_x4v3/export.py b/qai_hub_models/models/real_esrgan_general_x4v3/export.py index 78f52202..4f86924c 100644 --- a/qai_hub_models/models/real_esrgan_general_x4v3/export.py +++ b/qai_hub_models/models/real_esrgan_general_x4v3/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "real_esrgan_general_x4v3" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "real_esrgan_general_x4v3", diff --git a/qai_hub_models/models/real_esrgan_x4plus/README.md b/qai_hub_models/models/real_esrgan_x4plus/README.md index b4bb3d0d..dcd06bc0 100644 --- a/qai_hub_models/models/real_esrgan_x4plus/README.md +++ b/qai_hub_models/models/real_esrgan_x4plus/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Real-ESRGAN-x4plus can be found [here](https://github.com/xinntao/Real-ESRGAN/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data](https://arxiv.org/abs/2107.10833) * [Source Model Implementation](https://github.com/xinntao/Real-ESRGAN) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/real_esrgan_x4plus/export.py b/qai_hub_models/models/real_esrgan_x4plus/export.py index b37ecdda..c0bade9f 100644 --- a/qai_hub_models/models/real_esrgan_x4plus/export.py +++ b/qai_hub_models/models/real_esrgan_x4plus/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -41,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -71,7 +71,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -85,7 +85,6 @@ def export_model( """ model_name = "real_esrgan_x4plus" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "real_esrgan_x4plus", diff --git a/qai_hub_models/models/regnet/README.md b/qai_hub_models/models/regnet/README.md index 2a1a1082..3c1daee4 100644 --- a/qai_hub_models/models/regnet/README.md +++ b/qai_hub_models/models/regnet/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of RegNet can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Designing Network Design Spaces](https://arxiv.org/abs/2003.13678) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/regnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/regnet/export.py b/qai_hub_models/models/regnet/export.py index abc1ad63..ff916e30 100644 --- a/qai_hub_models/models/regnet/export.py +++ b/qai_hub_models/models/regnet/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "regnet" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "regnet", diff --git a/qai_hub_models/models/resnet101/README.md b/qai_hub_models/models/resnet101/README.md index f4701eef..89ba31b4 100644 --- a/qai_hub_models/models/resnet101/README.md +++ b/qai_hub_models/models/resnet101/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNet101 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnet101/export.py b/qai_hub_models/models/resnet101/export.py index 7b7ea302..d9c41ba1 100644 --- a/qai_hub_models/models/resnet101/export.py +++ b/qai_hub_models/models/resnet101/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "resnet101" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnet101", diff --git a/qai_hub_models/models/resnet101_quantized/README.md b/qai_hub_models/models/resnet101_quantized/README.md index 4f165dfb..e63d7647 100644 --- a/qai_hub_models/models/resnet101_quantized/README.md +++ b/qai_hub_models/models/resnet101_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNet101Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnet101_quantized/export.py b/qai_hub_models/models/resnet101_quantized/export.py index 5ddadd22..01fb1b0c 100644 --- a/qai_hub_models/models/resnet101_quantized/export.py +++ b/qai_hub_models/models/resnet101_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.resnet101_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "resnet101_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnet101_quantized", @@ -181,7 +179,9 @@ def export_model( torch_out = torch_inference(model, sample_inputs) assert inference_job.wait().success inference_result = inference_job.download_output_data() - print_inference_metrics(inference_job, inference_result, torch_out) + print_inference_metrics( + inference_job, inference_result, torch_out, metrics="psnr,top1,top5" + ) print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) diff --git a/qai_hub_models/models/resnet101_quantized/model.py b/qai_hub_models/models/resnet101_quantized/model.py index 1248f5a1..3ff4ad4c 100644 --- a/qai_hub_models/models/resnet101_quantized/model.py +++ b/qai_hub_models/models/resnet101_quantized/model.py @@ -8,6 +8,7 @@ # This verifies aimet is installed, and this must be included first. from qai_hub_models.utils.quantization_aimet import ( AIMETQuantizableMixin, + HubCompileOptionsInt8Mixin, ) # isort: on @@ -28,7 +29,9 @@ DEFAULT_ENCODINGS = "resnet101_quantized_encodings.json" -class ResNet101Quantizable(AIMETQuantizableMixin, ResNet101): +class ResNet101Quantizable( + HubCompileOptionsInt8Mixin, AIMETQuantizableMixin, ResNet101 +): """ResNet101 with post train quantization support. Supports only 8 bit weights and activations, and only loads pre-quantized checkpoints. diff --git a/qai_hub_models/models/resnet18/README.md b/qai_hub_models/models/resnet18/README.md index f80fd950..a8cfa9e5 100644 --- a/qai_hub_models/models/resnet18/README.md +++ b/qai_hub_models/models/resnet18/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNet18 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnet18/export.py b/qai_hub_models/models/resnet18/export.py index 66132e7a..b01f4ead 100644 --- a/qai_hub_models/models/resnet18/export.py +++ b/qai_hub_models/models/resnet18/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "resnet18" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnet18", diff --git a/qai_hub_models/models/resnet18_quantized/README.md b/qai_hub_models/models/resnet18_quantized/README.md index 5b2a2518..57c4c3b3 100644 --- a/qai_hub_models/models/resnet18_quantized/README.md +++ b/qai_hub_models/models/resnet18_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNet18Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnet18_quantized/export.py b/qai_hub_models/models/resnet18_quantized/export.py index 47adb241..0d8d0e85 100644 --- a/qai_hub_models/models/resnet18_quantized/export.py +++ b/qai_hub_models/models/resnet18_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.resnet18_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "resnet18_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnet18_quantized", @@ -181,7 +179,9 @@ def export_model( torch_out = torch_inference(model, sample_inputs) assert inference_job.wait().success inference_result = inference_job.download_output_data() - print_inference_metrics(inference_job, inference_result, torch_out) + print_inference_metrics( + inference_job, inference_result, torch_out, metrics="psnr,top1,top5" + ) print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) @@ -190,7 +190,7 @@ def export_model( def main(): warnings.filterwarnings("ignore") - parser = export_parser(model_cls=Model, supports_qnn=False) + parser = export_parser(model_cls=Model) args = parser.parse_args() export_model(**vars(args)) diff --git a/qai_hub_models/models/resnet18_quantized/model.py b/qai_hub_models/models/resnet18_quantized/model.py index 8a650fd3..7641d899 100644 --- a/qai_hub_models/models/resnet18_quantized/model.py +++ b/qai_hub_models/models/resnet18_quantized/model.py @@ -8,6 +8,7 @@ # This verifies aimet is installed, and this must be included first. from qai_hub_models.utils.quantization_aimet import ( AIMETQuantizableMixin, + HubCompileOptionsInt8Mixin, ) # isort: on @@ -17,15 +18,16 @@ from aimet_torch.quantsim import QuantizationSimModel, load_encodings_to_sim from qai_hub_models.models.resnet18.model import ResNet18 -from qai_hub_models.utils.aimet.config_loader import get_per_channel_aimet_config +from qai_hub_models.utils.aimet.config_loader import get_aimet_config_path from qai_hub_models.utils.asset_loaders import CachedWebModelAsset MODEL_ID = __name__.split(".")[-2] -MODEL_ASSET_VERSION = 5 +MODEL_ASSET_VERSION = 6 DEFAULT_ENCODINGS = "resnet18_quantized_encodings.json" +AIMET_CONFIG = "default_config_per_channel_qnn" -class ResNet18Quantizable(AIMETQuantizableMixin, ResNet18): +class ResNet18Quantizable(HubCompileOptionsInt8Mixin, AIMETQuantizableMixin, ResNet18): """ResNet with post train quantization support. Supports only 8 bit weights and activations, and only loads pre-quantized checkpoints. @@ -61,7 +63,7 @@ def from_pretrained( quant_scheme="tf_enhanced", default_param_bw=8, default_output_bw=8, - config_file=get_per_channel_aimet_config(), + config_file=get_aimet_config_path(AIMET_CONFIG), dummy_input=torch.rand(input_shape), ) diff --git a/qai_hub_models/models/resnet18_quantized/perf.yaml b/qai_hub_models/models/resnet18_quantized/perf.yaml index ba508ccb..38fc614e 100644 --- a/qai_hub_models/models/resnet18_quantized/perf.yaml +++ b/qai_hub_models/models/resnet18_quantized/perf.yaml @@ -28,35 +28,35 @@ models: - name: ResNet18Quantized performance_metrics: - torchscript_onnx_tflite: - inference_time: 50502.0 - throughput: 19.801195992237933 + inference_time: 375.0 + throughput: 2666.6666666666665 estimated_peak_memory_range: - min: 49152 - max: 14562768 + min: 12288 + max: 14684784 primary_compute_unit: NPU precision: fp16 layer_info: - layers_on_npu: 40 + layers_on_npu: 37 layers_on_gpu: 0 layers_on_cpu: 0 - total_layers: 40 - job_id: jegnzmrvg + total_layers: 37 + job_id: j2p0mj06g job_status: Passed torchscript_onnx_qnn: - inference_time: 'null' - throughput: 'null' + inference_time: 359.0 + throughput: 2785.515320334262 estimated_peak_memory_range: - min: 0 - max: 0 - primary_compute_unit: 'null' - precision: 'null' + min: 12288 + max: 71291800 + primary_compute_unit: NPU + precision: fp16 layer_info: - layers_on_npu: 0 + layers_on_npu: 35 layers_on_gpu: 0 layers_on_cpu: 0 - total_layers: 0 - job_id: '' - job_status: Skipped + total_layers: 35 + job_id: j1glyxm85 + job_status: Passed reference_device_info: name: Samsung Galaxy S23 Ultra os: '13' @@ -64,4 +64,4 @@ models: os_name: Android manufacturer: Samsung chipset: Snapdragon® 8 Gen 2 - timestamp: '2024-02-21T16:33:04.350551Z' + timestamp: '2024-02-23T04:45:17.544674Z' diff --git a/qai_hub_models/models/resnet50/README.md b/qai_hub_models/models/resnet50/README.md index 66d0a0e8..0c1e5cd2 100644 --- a/qai_hub_models/models/resnet50/README.md +++ b/qai_hub_models/models/resnet50/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNet50 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnet50/export.py b/qai_hub_models/models/resnet50/export.py index c72917fc..ceacf649 100644 --- a/qai_hub_models/models/resnet50/export.py +++ b/qai_hub_models/models/resnet50/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "resnet50" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnet50", diff --git a/qai_hub_models/models/resnext101/README.md b/qai_hub_models/models/resnext101/README.md index f8dd7a49..d8b65802 100644 --- a/qai_hub_models/models/resnext101/README.md +++ b/qai_hub_models/models/resnext101/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNeXt101 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Aggregated Residual Transformations for Deep Neural Networks](https://arxiv.org/abs/1611.05431) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnext101/export.py b/qai_hub_models/models/resnext101/export.py index b6a88bfe..5d591b8f 100644 --- a/qai_hub_models/models/resnext101/export.py +++ b/qai_hub_models/models/resnext101/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "resnext101" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnext101", diff --git a/qai_hub_models/models/resnext101_quantized/README.md b/qai_hub_models/models/resnext101_quantized/README.md index 51d5dd6f..10afa2cc 100644 --- a/qai_hub_models/models/resnext101_quantized/README.md +++ b/qai_hub_models/models/resnext101_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNeXt101Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Aggregated Residual Transformations for Deep Neural Networks](https://arxiv.org/abs/1611.05431) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnext101_quantized/export.py b/qai_hub_models/models/resnext101_quantized/export.py index cb8ccba0..ed09dd42 100644 --- a/qai_hub_models/models/resnext101_quantized/export.py +++ b/qai_hub_models/models/resnext101_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.resnext101_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "resnext101_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnext101_quantized", @@ -181,7 +179,9 @@ def export_model( torch_out = torch_inference(model, sample_inputs) assert inference_job.wait().success inference_result = inference_job.download_output_data() - print_inference_metrics(inference_job, inference_result, torch_out) + print_inference_metrics( + inference_job, inference_result, torch_out, metrics="psnr,top1,top5" + ) print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) diff --git a/qai_hub_models/models/resnext101_quantized/model.py b/qai_hub_models/models/resnext101_quantized/model.py index 6a3bfa56..9a6277e1 100644 --- a/qai_hub_models/models/resnext101_quantized/model.py +++ b/qai_hub_models/models/resnext101_quantized/model.py @@ -8,6 +8,7 @@ # This verifies aimet is installed, and this must be included first. from qai_hub_models.utils.quantization_aimet import ( AIMETQuantizableMixin, + HubCompileOptionsInt8Mixin, ) # isort: on @@ -25,7 +26,9 @@ DEFAULT_ENCODINGS = "resnext101_quantized_encodings.json" -class ResNeXt101Quantizable(AIMETQuantizableMixin, ResNeXt101): +class ResNeXt101Quantizable( + HubCompileOptionsInt8Mixin, AIMETQuantizableMixin, ResNeXt101 +): """ResNeXt101 with post train quantization support. Supports only 8 bit weights and activations, and only loads pre-quantized checkpoints. diff --git a/qai_hub_models/models/resnext50/README.md b/qai_hub_models/models/resnext50/README.md index 60c0361d..4a9dd3b8 100644 --- a/qai_hub_models/models/resnext50/README.md +++ b/qai_hub_models/models/resnext50/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of ResNeXt50 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Aggregated Residual Transformations for Deep Neural Networks](https://arxiv.org/abs/1611.05431) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/resnext50/export.py b/qai_hub_models/models/resnext50/export.py index 633926fd..ecdcf293 100644 --- a/qai_hub_models/models/resnext50/export.py +++ b/qai_hub_models/models/resnext50/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "resnext50" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "resnext50", diff --git a/qai_hub_models/models/sam/README.md b/qai_hub_models/models/sam/README.md index 3c30d212..9c36523d 100644 --- a/qai_hub_models/models/sam/README.md +++ b/qai_hub_models/models/sam/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Segment-Anything-Model can be found [here](https://github.com/facebookresearch/segment-anything/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Segment Anything](https://arxiv.org/abs/2304.02643) * [Source Model Implementation](https://github.com/facebookresearch/segment-anything) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/sam/export.py b/qai_hub_models/models/sam/export.py index 01c81a28..0ebb9f97 100644 --- a/qai_hub_models/models/sam/export.py +++ b/qai_hub_models/models/sam/export.py @@ -17,11 +17,8 @@ from torch.utils.mobile_optimizer import MobileOptimizerType, optimize_for_mobile from qai_hub_models.models.sam import Model -from qai_hub_models.utils.args import ( - export_parser, - get_model_kwargs, - parse_target_runtime, -) +from qai_hub_models.utils.args import export_parser, get_model_kwargs +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -45,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -78,7 +75,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -92,7 +89,6 @@ def export_model( """ model_name = "sam" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) component_arg = components components = components or DEFAULT_COMPONENTS for component in components: diff --git a/qai_hub_models/models/sesr_m5/README.md b/qai_hub_models/models/sesr_m5/README.md index 2cad4d05..fb9b84ea 100644 --- a/qai_hub_models/models/sesr_m5/README.md +++ b/qai_hub_models/models/sesr_m5/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of SESR-M5 can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Collapsible Linear Blocks for Super-Efficient Super Resolution](https://arxiv.org/abs/2103.09404) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/sesr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/sesr_m5/export.py b/qai_hub_models/models/sesr_m5/export.py index 76a2ce93..c857a7c6 100644 --- a/qai_hub_models/models/sesr_m5/export.py +++ b/qai_hub_models/models/sesr_m5/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "sesr_m5" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "sesr_m5", diff --git a/qai_hub_models/models/sesr_m5_quantized/README.md b/qai_hub_models/models/sesr_m5_quantized/README.md index 7b5358b3..3816090c 100644 --- a/qai_hub_models/models/sesr_m5_quantized/README.md +++ b/qai_hub_models/models/sesr_m5_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of SESR-M5-Quantized can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Collapsible Linear Blocks for Super-Efficient Super Resolution](https://arxiv.org/abs/2103.09404) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/sesr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/sesr_m5_quantized/export.py b/qai_hub_models/models/sesr_m5_quantized/export.py index f3cda7c2..9084e32a 100644 --- a/qai_hub_models/models/sesr_m5_quantized/export.py +++ b/qai_hub_models/models/sesr_m5_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.sesr_m5_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -42,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -72,7 +71,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -86,7 +85,6 @@ def export_model( """ model_name = "sesr_m5_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "sesr_m5_quantized", diff --git a/qai_hub_models/models/sesr_m5_quantized/model.py b/qai_hub_models/models/sesr_m5_quantized/model.py index c3cf1b57..4e85a042 100644 --- a/qai_hub_models/models/sesr_m5_quantized/model.py +++ b/qai_hub_models/models/sesr_m5_quantized/model.py @@ -4,6 +4,14 @@ # --------------------------------------------------------------------- from __future__ import annotations +# isort: off +# This verifies aimet is installed, and this must be included first. +from qai_hub_models.utils.quantization_aimet import ( + AIMETQuantizableMixin, +) + +# isort: on + import torch from aimet_torch.cross_layer_equalization import equalize_model from aimet_torch.quantsim import QuantizationSimModel, load_encodings_to_sim @@ -17,12 +25,6 @@ ) from qai_hub_models.utils.asset_loaders import CachedWebModelAsset -# This verifies aimet is installed, and this must be included first. -from qai_hub_models.utils.quantization_aimet import ( # isort: skip - AIMETQuantizableMixin, -) - - MODEL_ID = __name__.split(".")[-2] MODEL_ASSET_VERSION = 2 diff --git a/qai_hub_models/models/shufflenet_v2/README.md b/qai_hub_models/models/shufflenet_v2/README.md index 41addb61..ee5bc7c7 100644 --- a/qai_hub_models/models/shufflenet_v2/README.md +++ b/qai_hub_models/models/shufflenet_v2/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Shufflenet-v2 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design](https://arxiv.org/abs/1807.11164) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/shufflenetv2.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/shufflenet_v2/export.py b/qai_hub_models/models/shufflenet_v2/export.py index 1aef879e..74fd2aae 100644 --- a/qai_hub_models/models/shufflenet_v2/export.py +++ b/qai_hub_models/models/shufflenet_v2/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "shufflenet_v2" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "shufflenet_v2", diff --git a/qai_hub_models/models/shufflenet_v2_quantized/README.md b/qai_hub_models/models/shufflenet_v2_quantized/README.md index 0eeda872..f2486508 100644 --- a/qai_hub_models/models/shufflenet_v2_quantized/README.md +++ b/qai_hub_models/models/shufflenet_v2_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Shufflenet-v2Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design](https://arxiv.org/abs/1807.11164) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/shufflenetv2.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/shufflenet_v2_quantized/export.py b/qai_hub_models/models/shufflenet_v2_quantized/export.py index 4e3c03fe..27e330aa 100644 --- a/qai_hub_models/models/shufflenet_v2_quantized/export.py +++ b/qai_hub_models/models/shufflenet_v2_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.shufflenet_v2_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "shufflenet_v2_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "shufflenet_v2_quantized", @@ -181,7 +179,9 @@ def export_model( torch_out = torch_inference(model, sample_inputs) assert inference_job.wait().success inference_result = inference_job.download_output_data() - print_inference_metrics(inference_job, inference_result, torch_out) + print_inference_metrics( + inference_job, inference_result, torch_out, metrics="psnr,top1,top5" + ) print_on_target_demo_cmd(compile_job, Path(__file__).parent.resolve(), device) @@ -190,7 +190,7 @@ def export_model( def main(): warnings.filterwarnings("ignore") - parser = export_parser(model_cls=Model) + parser = export_parser(model_cls=Model, supports_qnn=False) args = parser.parse_args() export_model(**vars(args)) diff --git a/qai_hub_models/models/shufflenet_v2_quantized/model.py b/qai_hub_models/models/shufflenet_v2_quantized/model.py index 5d2c4f06..b6121793 100644 --- a/qai_hub_models/models/shufflenet_v2_quantized/model.py +++ b/qai_hub_models/models/shufflenet_v2_quantized/model.py @@ -8,6 +8,7 @@ # This verifies aimet is installed, and this must be included first. from qai_hub_models.utils.quantization_aimet import ( AIMETQuantizableMixin, + HubCompileOptionsInt8Mixin, ) # isort: on @@ -25,7 +26,9 @@ DEFAULT_ENCODINGS = "shufflenet_v2_quantized_encodings.json" -class ShufflenetV2Quantizable(AIMETQuantizableMixin, ShufflenetV2): +class ShufflenetV2Quantizable( + HubCompileOptionsInt8Mixin, AIMETQuantizableMixin, ShufflenetV2 +): """ShufflenetV2 with post train quantization support. Supports only 8 bit weights and activations, and only loads pre-quantized checkpoints. diff --git a/qai_hub_models/models/sinet/README.md b/qai_hub_models/models/sinet/README.md index 660348f9..4c69df34 100644 --- a/qai_hub_models/models/sinet/README.md +++ b/qai_hub_models/models/sinet/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of SINet can be found [here](https://github.com/clovaai/ext_portrait_segmentation/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [SINet: Extreme Lightweight Portrait Segmentation Networks with Spatial Squeeze Modules and Information Blocking Decoder](https://arxiv.org/abs/1911.09099) * [Source Model Implementation](https://github.com/clovaai/ext_portrait_segmentation) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/sinet/export.py b/qai_hub_models/models/sinet/export.py index 4b0fc545..3e9d21c7 100644 --- a/qai_hub_models/models/sinet/export.py +++ b/qai_hub_models/models/sinet/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "sinet" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "sinet", diff --git a/qai_hub_models/models/squeezenet1_1/README.md b/qai_hub_models/models/squeezenet1_1/README.md index 1c424ec0..428ddc4b 100644 --- a/qai_hub_models/models/squeezenet1_1/README.md +++ b/qai_hub_models/models/squeezenet1_1/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of SqueezeNet-1_1 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size](https://arxiv.org/abs/1602.07360) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/squeezenet1_1/export.py b/qai_hub_models/models/squeezenet1_1/export.py index 920ba9e6..9c1da861 100644 --- a/qai_hub_models/models/squeezenet1_1/export.py +++ b/qai_hub_models/models/squeezenet1_1/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "squeezenet1_1" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "squeezenet1_1", diff --git a/qai_hub_models/models/squeezenet1_1_quantized/README.md b/qai_hub_models/models/squeezenet1_1_quantized/README.md index 4829dd66..4caa3b8a 100644 --- a/qai_hub_models/models/squeezenet1_1_quantized/README.md +++ b/qai_hub_models/models/squeezenet1_1_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of SqueezeNet-1_1Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size](https://arxiv.org/abs/1602.07360) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/squeezenet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/squeezenet1_1_quantized/export.py b/qai_hub_models/models/squeezenet1_1_quantized/export.py index 552d6632..8e42fb41 100644 --- a/qai_hub_models/models/squeezenet1_1_quantized/export.py +++ b/qai_hub_models/models/squeezenet1_1_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.squeezenet1_1_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "squeezenet1_1_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "squeezenet1_1_quantized", diff --git a/qai_hub_models/models/stable_diffusion_quantized/README.md b/qai_hub_models/models/stable_diffusion_quantized/README.md index 4bd0f303..9cd69d99 100644 --- a/qai_hub_models/models/stable_diffusion_quantized/README.md +++ b/qai_hub_models/models/stable_diffusion_quantized/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Stable-Diffusion can be found [here](https://github.com/CompVis/stable-diffusion/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [High-Resolution Image Synthesis with Latent Diffusion Models](https://arxiv.org/abs/2112.10752) * [Source Model Implementation](https://github.com/CompVis/stable-diffusion/tree/main) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/stable_diffusion_quantized/demo.py b/qai_hub_models/models/stable_diffusion_quantized/demo.py index de1dacbb..d95ec30e 100644 --- a/qai_hub_models/models/stable_diffusion_quantized/demo.py +++ b/qai_hub_models/models/stable_diffusion_quantized/demo.py @@ -12,6 +12,8 @@ from qai_hub_models.models.stable_diffusion_quantized.app import StableDiffusionApp from qai_hub_models.models.stable_diffusion_quantized.model import ( + MODEL_ASSET_VERSION, + MODEL_ID, ClipVITTextEncoder, Unet, VAEDecoder, @@ -19,21 +21,32 @@ from qai_hub_models.utils.args import add_output_dir_arg from qai_hub_models.utils.base_model import BasePrecompiledModel from qai_hub_models.utils.display import display_or_save_image -from qai_hub_models.utils.inference import HubModel +from qai_hub_models.utils.inference import HubModel, get_uploaded_precompiled_model from qai_hub_models.utils.qai_hub_helpers import can_access_qualcomm_ai_hub DEFAULT_DEMO_PROMPT = "spectacular view of northern lights from Alaska" DEFAULT_DEVICE_NAME = "Samsung Galaxy S23 Ultra" -def _get_hub_model(input_model: BasePrecompiledModel, device_name=DEFAULT_DEVICE_NAME): +def _get_hub_model( + input_model: BasePrecompiledModel, + model_name: str, + ignore_cached_model: bool = False, + device_name=DEFAULT_DEVICE_NAME, +): if not can_access_qualcomm_ai_hub(): raise RuntimeError( "Stable-diffusion on-device demo requires access to QAI-Hub.\n" "Please visit https://aihub.qualcomm.com/ and sign-up." ) # Upload model - uploaded_model = hub.upload_model(input_model.get_target_model_path()) + uploaded_model = get_uploaded_precompiled_model( + input_model.get_target_model_path(), + MODEL_ID, + MODEL_ASSET_VERSION, + model_name, + ignore_cached_model=ignore_cached_model, + ) inputs = list(input_model.get_input_spec().keys()) return HubModel(uploaded_model, inputs, hub.Device(name=device_name)) @@ -49,7 +62,7 @@ def main(is_test: bool = False): ) parser.add_argument( "--num-steps", - default=2, + default=5, type=int, help="The number of diffusion iteration steps (higher means better quality).", ) @@ -66,6 +79,11 @@ def main(is_test: bool = False): default=7.5, help="Strength of guidance (higher means more influence from prompt).", ) + parser.add_argument( + "--ignore-cached-model", + action="store_true", + help="Uploads model ignoring previously uploaded and cached model.", + ) parser.add_argument( "--device-name", type=str, @@ -86,7 +104,7 @@ def main(is_test: bool = False): print("Seed:", args.seed) print() print( - "Note: This reference demo uses significant amounts of memory and may take 5-10 minutes to run per step." + "Note: This reference demo uses significant amounts of memory and may take 4-5 minutes to run ** per step **." ) print(f"{'-' * 100}\n") @@ -101,9 +119,13 @@ def main(is_test: bool = False): # Instead of forward, we later submit inference_jobs on QAI-Hub for # on-device evaluation. print(f"Uploading model assets on QAI-Hub\n{'-' * 35}") - text_encoder = _get_hub_model(text_encoder, args.device_name) - unet = _get_hub_model(unet, args.device_name) - vae_decoder = _get_hub_model(vae_decoder, args.device_name) + text_encoder = _get_hub_model( + text_encoder, "text_encoder", args.ignore_cached_model, args.device_name + ) + unet = _get_hub_model(unet, "unet", args.ignore_cached_model, args.device_name) + vae_decoder = _get_hub_model( + vae_decoder, "vae_decoder", args.ignore_cached_model, args.device_name + ) # Create tokenizer, scheduler and time_embedding required # for stable-diffusion pipeline. diff --git a/qai_hub_models/models/stable_diffusion_quantized/export.py b/qai_hub_models/models/stable_diffusion_quantized/export.py index 532f23b2..5f9280bd 100644 --- a/qai_hub_models/models/stable_diffusion_quantized/export.py +++ b/qai_hub_models/models/stable_diffusion_quantized/export.py @@ -14,15 +14,20 @@ import qai_hub as hub from qai_hub_models.models.stable_diffusion_quantized import Model -from qai_hub_models.utils.args import TargetRuntime, export_parser +from qai_hub_models.utils.args import export_parser +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.printing import print_profile_metrics_from_job from qai_hub_models.utils.qai_hub_helpers import ( can_access_qualcomm_ai_hub, export_without_hub_access, ) -ALL_COMPONENTS = ["text_encoder", "unet", "vae_decoder"] -DEFAULT_COMPONENTS = ["text_encoder", "vae_decoder", "unet"] +ALL_COMPONENTS = ["Text-Encoder-Quantized", "UNet-Quantized", "VAE-Decoder-Quantized"] +DEFAULT_COMPONENTS = [ + "Text-Encoder-Quantized", + "VAE-Decoder-Quantized", + "UNet-Quantized", +] def export_model( @@ -97,12 +102,12 @@ def export_model( print("Initializing model class") model = Model.from_precompiled() components_dict = {} - if "text_encoder" in components: - components_dict["text_encoder"] = model.text_encoder - if "unet" in components: - components_dict["unet"] = model.unet - if "vae_decoder" in components: - components_dict["vae_decoder"] = model.vae_decoder + if "Text-Encoder-Quantized" in components: + components_dict["Text-Encoder-Quantized"] = model.text_encoder + if "UNet-Quantized" in components: + components_dict["UNet-Quantized"] = model.unet + if "VAE-Decoder-Quantized" in components: + components_dict["VAE-Decoder-Quantized"] = model.vae_decoder # 2. Upload model assets to hub print("Uploading model assets on hub") diff --git a/qai_hub_models/models/stable_diffusion_quantized/perf.yaml b/qai_hub_models/models/stable_diffusion_quantized/perf.yaml index 36014f84..3ece0dbf 100644 --- a/qai_hub_models/models/stable_diffusion_quantized/perf.yaml +++ b/qai_hub_models/models/stable_diffusion_quantized/perf.yaml @@ -1,5 +1,5 @@ models: -- name: Text-Encoder-Quantized +- name: TextEncoder_Quantized performance_metrics: - reference_device_info: name: Samsung Galaxy S23 @@ -24,7 +24,7 @@ models: primary_compute_unit: NPU job_id: jo5m87owp job_status: Passed -- name: VAE-Decoder-Quantized +- name: VAEDecoder_Quantized performance_metrics: - reference_device_info: name: Samsung Galaxy S23 @@ -49,7 +49,7 @@ models: primary_compute_unit: NPU job_id: joprwro95 job_status: Passed -- name: UNet-Quantized +- name: UNet_Quantized performance_metrics: - reference_device_info: name: Samsung Galaxy S23 diff --git a/qai_hub_models/models/stylegan2/README.md b/qai_hub_models/models/stylegan2/README.md index 25bdb7e1..74acda7f 100644 --- a/qai_hub_models/models/stylegan2/README.md +++ b/qai_hub_models/models/stylegan2/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of StyleGAN2 can be found [here](https://github.com/NVlabs/stylegan3/blob/main/LICENSE.txt). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Analyzing and Improving the Image Quality of StyleGAN](http://arxiv.org/abs/1912.04958) * [Source Model Implementation](https://github.com/NVlabs/stylegan3) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/stylegan2/app.py b/qai_hub_models/models/stylegan2/app.py index 0f34df19..f0c4c304 100644 --- a/qai_hub_models/models/stylegan2/app.py +++ b/qai_hub_models/models/stylegan2/app.py @@ -32,7 +32,9 @@ def generate_random_vec(self, batch_size=1, seed=None) -> torch.Tensor: self.model.sample_inputs(input_spec, seed=seed)["image_noise"][0] ) return torch.from_numpy( - np.random.RandomState(seed).randn(batch_size, self.output_dims) + np.random.RandomState(seed) + .randn(batch_size, self.output_dims) + .astype(np.float32) ) def predict(self, *args, **kwargs): diff --git a/qai_hub_models/models/stylegan2/demo.py b/qai_hub_models/models/stylegan2/demo.py index 62560946..e3d0f99e 100644 --- a/qai_hub_models/models/stylegan2/demo.py +++ b/qai_hub_models/models/stylegan2/demo.py @@ -7,15 +7,20 @@ from qai_hub_models.models.stylegan2.app import StyleGAN2App from qai_hub_models.models.stylegan2.model import StyleGAN2 from qai_hub_models.utils.args import ( - add_output_dir_arg, + demo_model_from_cli_args, get_model_cli_parser, + get_on_device_demo_parser, model_from_cli_args, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.display import display_or_save_image def main(is_test: bool = False): parser = get_model_cli_parser(StyleGAN2) + parser = get_on_device_demo_parser( + parser, available_target_runtimes=[TargetRuntime.TFLITE], add_output_dir=True + ) parser.add_argument( "--seed", type=int, @@ -26,9 +31,8 @@ def main(is_test: bool = False): "--num-images", type=int, default=1, - help="Number of images to generate (all computed in 1 inference call).", + help="Number of images to generate (all computed in one inference call).", ) - add_output_dir_arg(parser) parser.add_argument( "--classes", type=int, @@ -37,11 +41,13 @@ def main(is_test: bool = False): help="Class[es] to use for image generation (if applicable).", ) args = parser.parse_args([] if is_test else None) + if not args.inference_options: + args.inference_options = "--compute_unit gpu" # Create model and app model = model_from_cli_args(StyleGAN2, args) - assert isinstance(model, StyleGAN2) - app = StyleGAN2App(model, model.output_size, model.num_classes) + inference_model = demo_model_from_cli_args(StyleGAN2, args) + app = StyleGAN2App(inference_model, model.output_size, model.num_classes) # Verify model input args if model.num_classes == 0 and args.classes: diff --git a/qai_hub_models/models/stylegan2/export.py b/qai_hub_models/models/stylegan2/export.py index e08ad817..0ac5ef8c 100644 --- a/qai_hub_models/models/stylegan2/export.py +++ b/qai_hub_models/models/stylegan2/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -42,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -72,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -86,7 +86,6 @@ def export_model( """ model_name = "stylegan2" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "stylegan2", diff --git a/qai_hub_models/models/stylegan2/model.py b/qai_hub_models/models/stylegan2/model.py index 13d59c56..eddb21cd 100644 --- a/qai_hub_models/models/stylegan2/model.py +++ b/qai_hub_models/models/stylegan2/model.py @@ -106,7 +106,7 @@ def sample_inputs( ] } if "classes" in input_spec: - classes = np.zeros(input_spec["classes"][0]).astype(np.float32) + classes = np.zeros(input_spec["classes"][0], dtype=np.float32) if input_spec["classes"][0][1] != 0: classes[:, 0] = 1 # Select first class as default inputs["classes"] = [classes] diff --git a/qai_hub_models/models/swin_base/README.md b/qai_hub_models/models/swin_base/README.md index 6d48fce0..bb0f1982 100644 --- a/qai_hub_models/models/swin_base/README.md +++ b/qai_hub_models/models/swin_base/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Swin-Base can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Swin Transformer: Hierarchical Vision Transformer using Shifted Windows](https://arxiv.org/abs/2103.14030) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/swin_transformer.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/swin_base/export.py b/qai_hub_models/models/swin_base/export.py index 58416857..50aa82df 100644 --- a/qai_hub_models/models/swin_base/export.py +++ b/qai_hub_models/models/swin_base/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "swin_base" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "swin_base", diff --git a/qai_hub_models/models/swin_small/README.md b/qai_hub_models/models/swin_small/README.md index de3c2ec5..9f0e1f3e 100644 --- a/qai_hub_models/models/swin_small/README.md +++ b/qai_hub_models/models/swin_small/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Swin-Small can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Swin Transformer: Hierarchical Vision Transformer using Shifted Windows](https://arxiv.org/abs/2103.14030) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/swin_transformer.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/swin_small/export.py b/qai_hub_models/models/swin_small/export.py index dabc8746..9e7505bb 100644 --- a/qai_hub_models/models/swin_small/export.py +++ b/qai_hub_models/models/swin_small/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "swin_small" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "swin_small", diff --git a/qai_hub_models/models/swin_tiny/README.md b/qai_hub_models/models/swin_tiny/README.md index 407b8fd2..90bad6d8 100644 --- a/qai_hub_models/models/swin_tiny/README.md +++ b/qai_hub_models/models/swin_tiny/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Swin-Tiny can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Swin Transformer: Hierarchical Vision Transformer using Shifted Windows](https://arxiv.org/abs/2103.14030) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/swin_transformer.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/swin_tiny/export.py b/qai_hub_models/models/swin_tiny/export.py index bc2550e3..28760804 100644 --- a/qai_hub_models/models/swin_tiny/export.py +++ b/qai_hub_models/models/swin_tiny/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "swin_tiny" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "swin_tiny", diff --git a/qai_hub_models/models/trocr/README.md b/qai_hub_models/models/trocr/README.md index 8c87e6a4..a336b1e5 100644 --- a/qai_hub_models/models/trocr/README.md +++ b/qai_hub_models/models/trocr/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of TrOCR can be found [here](https://github.com/microsoft/unilm/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models](https://arxiv.org/abs/2109.10282) * [Source Model Implementation](https://huggingface.co/microsoft/trocr-small-stage1) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/trocr/export.py b/qai_hub_models/models/trocr/export.py index 8f74baee..8ed66055 100644 --- a/qai_hub_models/models/trocr/export.py +++ b/qai_hub_models/models/trocr/export.py @@ -16,11 +16,8 @@ import torch from qai_hub_models.models.trocr import Model -from qai_hub_models.utils.args import ( - export_parser, - get_model_kwargs, - parse_target_runtime, -) +from qai_hub_models.utils.args import export_parser, get_model_kwargs +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +41,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -77,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -91,7 +88,6 @@ def export_model( """ model_name = "trocr" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) component_arg = components components = components or ALL_COMPONENTS for component in components: diff --git a/qai_hub_models/models/unet_segmentation/README.md b/qai_hub_models/models/unet_segmentation/README.md index 7e1b7c39..9923e7af 100644 --- a/qai_hub_models/models/unet_segmentation/README.md +++ b/qai_hub_models/models/unet_segmentation/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Unet-Segmentation can be found [here](https://github.com/milesial/Pytorch-UNet/blob/master/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [U-Net: Convolutional Networks for Biomedical Image Segmentation](https://arxiv.org/abs/1505.04597) * [Source Model Implementation](https://github.com/milesial/Pytorch-UNet) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/unet_segmentation/export.py b/qai_hub_models/models/unet_segmentation/export.py index d566a699..94d2b2c4 100644 --- a/qai_hub_models/models/unet_segmentation/export.py +++ b/qai_hub_models/models/unet_segmentation/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -44,7 +44,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -74,7 +74,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -88,7 +88,6 @@ def export_model( """ model_name = "unet_segmentation" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "unet_segmentation", diff --git a/qai_hub_models/models/vit/README.md b/qai_hub_models/models/vit/README.md index f1c29bfc..f5a92fec 100644 --- a/qai_hub_models/models/vit/README.md +++ b/qai_hub_models/models/vit/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of VIT can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale](https://arxiv.org/abs/2010.11929) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/vision_transformer.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/vit/export.py b/qai_hub_models/models/vit/export.py index 5ddfbd36..31a1ccfc 100644 --- a/qai_hub_models/models/vit/export.py +++ b/qai_hub_models/models/vit/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "vit" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "vit", diff --git a/qai_hub_models/models/whisper_asr/README.md b/qai_hub_models/models/whisper_asr/README.md index 593bd344..743bb60d 100644 --- a/qai_hub_models/models/whisper_asr/README.md +++ b/qai_hub_models/models/whisper_asr/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Whisper-Base can be found [here](https://github.com/openai/whisper/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Robust Speech Recognition via Large-Scale Weak Supervision](https://cdn.openai.com/papers/whisper.pdf) * [Source Model Implementation](https://github.com/openai/whisper/tree/main) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/whisper_asr/export.py b/qai_hub_models/models/whisper_asr/export.py index 122ea877..ece839b1 100644 --- a/qai_hub_models/models/whisper_asr/export.py +++ b/qai_hub_models/models/whisper_asr/export.py @@ -16,11 +16,8 @@ import torch from qai_hub_models.models.whisper_asr import Model -from qai_hub_models.utils.args import ( - export_parser, - get_model_kwargs, - parse_target_runtime, -) +from qai_hub_models.utils.args import export_parser, get_model_kwargs +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -30,7 +27,6 @@ from qai_hub_models.utils.qai_hub_helpers import ( can_access_qualcomm_ai_hub, export_without_hub_access, - transpose_channel_first_to_last, ) ALL_COMPONENTS = ["WhisperEncoder", "WhisperDecoder"] @@ -44,7 +40,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -77,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -91,7 +87,6 @@ def export_model( """ model_name = "whisper_asr" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) component_arg = components components = components or ALL_COMPONENTS for component in components: @@ -129,7 +124,7 @@ def export_model( # 2. Compile the models to an on-device asset model_compile_options = component.get_hub_compile_options( - target_runtime, compile_options + " --force_channel_last_input audio" + target_runtime, compile_options ) print(f"Optimizing model {component_name} to run on-device.") compile_jobs[component_name] = hub.submit_compile_job( @@ -160,13 +155,9 @@ def export_model( f"Running inference for {component_name} on a hosted device with example inputs." ) sample_inputs = components_dict[component_name].sample_inputs() - # Convert inputs from channel first to channel last - hub_inputs = transpose_channel_first_to_last( - "audio", sample_inputs, target_runtime - ) inference_jobs[component_name] = hub.submit_inference_job( model=compile_jobs[component_name].get_target_model(), - inputs=hub_inputs, + inputs=sample_inputs, device=hub.Device(device), name=f"{component_name}", options=profile_options, diff --git a/qai_hub_models/models/wideresnet50/README.md b/qai_hub_models/models/wideresnet50/README.md index a723b252..f4765642 100644 --- a/qai_hub_models/models/wideresnet50/README.md +++ b/qai_hub_models/models/wideresnet50/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of WideResNet50 can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Wide Residual Networks](https://arxiv.org/abs/1605.07146) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/wideresnet50/export.py b/qai_hub_models/models/wideresnet50/export.py index a43ffe10..023f1afc 100644 --- a/qai_hub_models/models/wideresnet50/export.py +++ b/qai_hub_models/models/wideresnet50/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "wideresnet50" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "wideresnet50", diff --git a/qai_hub_models/models/wideresnet50_quantized/README.md b/qai_hub_models/models/wideresnet50_quantized/README.md index a5ac6c61..2af28bfc 100644 --- a/qai_hub_models/models/wideresnet50_quantized/README.md +++ b/qai_hub_models/models/wideresnet50_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of WideResNet50-Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Wide Residual Networks](https://arxiv.org/abs/1605.07146) * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/wideresnet50_quantized/export.py b/qai_hub_models/models/wideresnet50_quantized/export.py index 77af46f4..4bad440d 100644 --- a/qai_hub_models/models/wideresnet50_quantized/export.py +++ b/qai_hub_models/models/wideresnet50_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.wideresnet50_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "wideresnet50_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "wideresnet50_quantized", diff --git a/qai_hub_models/models/xlsr/README.md b/qai_hub_models/models/xlsr/README.md index 742df1d9..1e74c7fb 100644 --- a/qai_hub_models/models/xlsr/README.md +++ b/qai_hub_models/models/xlsr/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of XLSR can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Extremely Lightweight Quantization Robust Real-Time Single-Image Super Resolution for Mobile Devices](https://arxiv.org/abs/2105.10288) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/xlsr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/xlsr/export.py b/qai_hub_models/models/xlsr/export.py index b0a7a751..b760df96 100644 --- a/qai_hub_models/models/xlsr/export.py +++ b/qai_hub_models/models/xlsr/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "xlsr" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "xlsr", diff --git a/qai_hub_models/models/xlsr_quantized/README.md b/qai_hub_models/models/xlsr_quantized/README.md index edf7ff13..cf3640eb 100644 --- a/qai_hub_models/models/xlsr_quantized/README.md +++ b/qai_hub_models/models/xlsr_quantized/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of XLSR-Quantized can be found [here](https://github.com/quic/aimet-model-zoo/blob/develop/LICENSE.pdf). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Extremely Lightweight Quantization Robust Real-Time Single-Image Super Resolution for Mobile Devices](https://arxiv.org/abs/2105.10288) * [Source Model Implementation](https://github.com/quic/aimet-model-zoo/tree/develop/aimet_zoo_torch/xlsr) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/xlsr_quantized/export.py b/qai_hub_models/models/xlsr_quantized/export.py index b26fde6b..9ae48155 100644 --- a/qai_hub_models/models/xlsr_quantized/export.py +++ b/qai_hub_models/models/xlsr_quantized/export.py @@ -16,12 +16,11 @@ from qai_hub_models.models.xlsr_quantized import Model from qai_hub_models.utils.args import ( - TargetRuntime, export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.printing import ( print_inference_metrics, @@ -43,7 +42,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +72,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +86,6 @@ def export_model( """ model_name = "xlsr_quantized" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "xlsr_quantized", diff --git a/qai_hub_models/models/xlsr_quantized/model.py b/qai_hub_models/models/xlsr_quantized/model.py index d9313440..9747be53 100644 --- a/qai_hub_models/models/xlsr_quantized/model.py +++ b/qai_hub_models/models/xlsr_quantized/model.py @@ -4,18 +4,20 @@ # --------------------------------------------------------------------- from __future__ import annotations +# isort: off +# This verifies aimet is installed, and this must be included first. +from qai_hub_models.utils.quantization_aimet import ( + AIMETQuantizableMixin, +) + +# isort: on + import torch from aimet_torch.quantsim import QuantizationSimModel, load_encodings_to_sim from qai_hub_models.models.xlsr.model import XLSR, _load_xlsr_source_model from qai_hub_models.utils.asset_loaders import CachedWebModelAsset -# This verifies aimet is installed, and this must be included first. -from qai_hub_models.utils.quantization_aimet import ( # isort: skip - AIMETQuantizableMixin, -) - - MODEL_ID = __name__.split(".")[-2] MODEL_ASSET_VERSION = 2 # Weights and config stored in S3 are sourced from diff --git a/qai_hub_models/models/yolov6/README.md b/qai_hub_models/models/yolov6/README.md index fa194543..5b7bb299 100644 --- a/qai_hub_models/models/yolov6/README.md +++ b/qai_hub_models/models/yolov6/README.md @@ -39,12 +39,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Yolo-v6 can be found [here](https://github.com/meituan/YOLOv6/blob/47625514e7480706a46ff3c0cd0252907ac12f22/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications](https://arxiv.org/abs/2209.02976) * [Source Model Implementation](https://github.com/meituan/YOLOv6/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/yolov6/export.py b/qai_hub_models/models/yolov6/export.py index 22f077b9..a425cd58 100644 --- a/qai_hub_models/models/yolov6/export.py +++ b/qai_hub_models/models/yolov6/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "yolov6" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "yolov6", diff --git a/qai_hub_models/models/yolov7/README.md b/qai_hub_models/models/yolov7/README.md index bb98d698..24ebb47f 100644 --- a/qai_hub_models/models/yolov7/README.md +++ b/qai_hub_models/models/yolov7/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Yolo-v7 can be found [here](https://github.com/WongKinYiu/yolov7/blob/main/LICENSE.md). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors](https://arxiv.org/abs/2207.02696) * [Source Model Implementation](https://github.com/WongKinYiu/yolov7/) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/yolov7/export.py b/qai_hub_models/models/yolov7/export.py index 45ac5a22..e58ad576 100644 --- a/qai_hub_models/models/yolov7/export.py +++ b/qai_hub_models/models/yolov7/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "yolov7" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "yolov7", diff --git a/qai_hub_models/models/yolov8_det/README.md b/qai_hub_models/models/yolov8_det/README.md index d2bb0e5c..b9412278 100644 --- a/qai_hub_models/models/yolov8_det/README.md +++ b/qai_hub_models/models/yolov8_det/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Yolo-v8-Detection can be found [here](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Real-Time Flying Object Detection with YOLOv8](https://arxiv.org/abs/2305.09972) * [Source Model Implementation](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/yolo/detect) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/yolov8_det/export.py b/qai_hub_models/models/yolov8_det/export.py index f9c24138..e26be3de 100644 --- a/qai_hub_models/models/yolov8_det/export.py +++ b/qai_hub_models/models/yolov8_det/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "yolov8_det" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "yolov8_det", diff --git a/qai_hub_models/models/yolov8_seg/README.md b/qai_hub_models/models/yolov8_seg/README.md index 4ccdd84f..474b9ac1 100644 --- a/qai_hub_models/models/yolov8_seg/README.md +++ b/qai_hub_models/models/yolov8_seg/README.md @@ -44,12 +44,16 @@ Additional options are documented with the `--help` option. Note that the above script requires access to Deployment instructions for Qualcomm® AI Hub. ## License -- Code in the Qualcomm® AI Hub Models repository is covered by the LICENSE - file at the repository root. - The license for the original implementation of Yolo-v8-Segmentation can be found [here](https://github.com/ultralytics/ultralytics/blob/main/LICENSE). - +- The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf). ## References * [Real-Time Flying Object Detection with YOLOv8](https://arxiv.org/abs/2305.09972) * [Source Model Implementation](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/yolo/segment) + +## Community +* Join [our AI Hub Slack community](https://join.slack.com/t/qualcommaihub-nac3926/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA) to collaborate, post questions and learn more about on-device AI. +* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com). + +{usage_and_limitation} diff --git a/qai_hub_models/models/yolov8_seg/export.py b/qai_hub_models/models/yolov8_seg/export.py index e8b4d7ae..366b63ea 100644 --- a/qai_hub_models/models/yolov8_seg/export.py +++ b/qai_hub_models/models/yolov8_seg/export.py @@ -20,8 +20,8 @@ export_parser, get_input_spec_kwargs, get_model_kwargs, - parse_target_runtime, ) +from qai_hub_models.utils.base_model import TargetRuntime from qai_hub_models.utils.compare import torch_inference from qai_hub_models.utils.input_spec import make_torch_inputs from qai_hub_models.utils.printing import ( @@ -43,7 +43,7 @@ def export_model( skip_downloading: bool = False, skip_summary: bool = False, output_dir: Optional[str] = None, - dst_runtime: str = "TFLITE", + target_runtime: TargetRuntime = TargetRuntime.TFLITE, compile_options: str = "", profile_options: str = "", **additional_model_kwargs, @@ -73,7 +73,7 @@ def export_model( from profiling and inference. output_dir: Directory to store generated assets (e.g. compiled model). Defaults to `/build/`. - dst_runtime: Which on-device runtime to target. Default is TensorFlowLite. + target_runtime: Which on-device runtime to target. Default is TFLite. compile_options: Additional options to pass when submitting the compile job. profile_options: Additional options to pass when submitting the profile job. **additional_model_kwargs: Additional optional kwargs used to customize @@ -87,7 +87,6 @@ def export_model( """ model_name = "yolov8_seg" output_path = Path(output_dir or Path.cwd() / "build" / model_name) - target_runtime = parse_target_runtime(dst_runtime) if not can_access_qualcomm_ai_hub(): return export_without_hub_access( "yolov8_seg", diff --git a/qai_hub_models/requirements-dev.txt b/qai_hub_models/requirements-dev.txt index 00cfe6e1..578fca5f 100644 --- a/qai_hub_models/requirements-dev.txt +++ b/qai_hub_models/requirements-dev.txt @@ -15,5 +15,6 @@ tensorflow-cpu==2.13.0; sys_platform != 'darwin' tensorflow-macos==2.13.0; sys_platform == 'darwin' types-PyYAML types-pillow +types-tabulate types-requests keyrings.envvars; python_version >= '3.9' # used only by CI diff --git a/qai_hub_models/requirements.txt b/qai_hub_models/requirements.txt index 6ba28b51..9e263481 100644 --- a/qai_hub_models/requirements.txt +++ b/qai_hub_models/requirements.txt @@ -5,13 +5,15 @@ huggingface_hub ipython numpy==1.23.1 opencv-python==4.8.1.78 +pandas prettytable pytest==7.4.2 pyyaml -qai_hub +qai_hub>=0.9.0 requests requests_toolbelt schema +tabulate torch==1.13.1 torchvision<=0.14.1 urllib3<2 diff --git a/qai_hub_models/utils/aimet/config_loader.py b/qai_hub_models/utils/aimet/config_loader.py index c7b63610..b18bcf0e 100644 --- a/qai_hub_models/utils/aimet/config_loader.py +++ b/qai_hub_models/utils/aimet/config_loader.py @@ -13,3 +13,8 @@ def get_default_aimet_config() -> str: def get_per_channel_aimet_config() -> str: path = Path(__file__).parent / "default_config_per_channel.json" return str(path.resolve()) + + +def get_aimet_config_path(name: str) -> str: + path = Path(__file__).parent / f"{name}.json" + return str(path.resolve()) diff --git a/qai_hub_models/utils/aimet/default_config_per_channel_qnn.json b/qai_hub_models/utils/aimet/default_config_per_channel_qnn.json new file mode 100644 index 00000000..e46e98db --- /dev/null +++ b/qai_hub_models/utils/aimet/default_config_per_channel_qnn.json @@ -0,0 +1,68 @@ +{ + "defaults": + { + "ops": + { + "is_output_quantized": "True" + }, + "params": + { + "is_quantized": "True", + "is_symmetric": "True" + }, + "strict_symmetric": "False", + "unsigned_symmetric": "True", + "per_channel_quantization": "True" + }, + + "params": + { + "bias": + { + "is_quantized": "False" + } + }, + + "op_type": + { + "Squeeze": + { + "is_output_quantized": "False" + }, + "Pad": + { + "is_output_quantized": "False" + }, + "Mean": + { + "is_output_quantized": "False" + } + }, + + "supergroups": + [ + { + "op_list": ["Conv", "Relu"] + }, + { + "op_list": ["Conv", "Clip"] + }, + { + "op_list": ["Conv", "BatchNormalization", "Relu"] + }, + { + "op_list": ["Add", "Relu"] + }, + { + "op_list": ["Gemm", "Relu"] + } + ], + + "model_input": + { + "is_input_quantized": "True" + }, + + "model_output": + {} +} diff --git a/qai_hub_models/utils/args.py b/qai_hub_models/utils/args.py index c9f53100..cbddf19c 100644 --- a/qai_hub_models/utils/args.py +++ b/qai_hub_models/utils/args.py @@ -11,6 +11,7 @@ import inspect import os import sys +from functools import partial from importlib import import_module from pydoc import locate from typing import Any, List, Mapping, Optional, Type @@ -31,8 +32,13 @@ DEFAULT_EXPORT_DEVICE = "Samsung Galaxy S23" -def parse_target_runtime(path: TargetRuntime | str) -> TargetRuntime: - return TargetRuntime[path.upper()] if isinstance(path, str) else path +class ParseEnumAction(argparse.Action): + def __init__(self, option_strings, dest, enum_type, **kwargs): + super().__init__(option_strings, dest, **kwargs) + self.enum_type = enum_type + + def __call__(self, parser, namespace, values, option_string=None): + setattr(namespace, self.dest, self.enum_type[values.upper()]) def get_parser() -> argparse.ArgumentParser: @@ -52,6 +58,22 @@ def add_output_dir_arg(parser: argparse.ArgumentParser) -> argparse.ArgumentPars return parser +def add_target_runtime_arg( + parser: argparse.ArgumentParser, + help: str, + default: TargetRuntime = TargetRuntime.TFLITE, +) -> argparse.ArgumentParser: + parser.add_argument( + "--target-runtime", + type=str, + action=partial(ParseEnumAction, enum_type=TargetRuntime), # type: ignore + default=default, + choices=[name.lower() for name in TargetRuntime._member_names_], + help=help, + ) + return parser + + def get_on_device_demo_parser( parser: argparse.ArgumentParser | None = None, available_target_runtimes: List[TargetRuntime] = list( @@ -98,11 +120,10 @@ def get_on_device_demo_parser( if TargetRuntime.TFLITE in available_target_runtimes else available_target_runtimes[0] ) - parser.add_argument( - "--target-runtime", - default=default_runtime.name, - help="The runtime to demo (if --on-device is specified). Default is TFLITE.", - choices=[x.name for x in available_target_runtimes], + add_target_runtime_arg( + parser, + help="The runtime to demo (if --on-device is specified).", + default=default_runtime, ) return parser @@ -202,7 +223,6 @@ def demo_model_from_cli_args( model_cls, cli_args ) # TODO(9494): This should be replaced by static input spec is_on_device = "on_device" in cli_args and cli_args.on_device - target_runtime = TargetRuntime[cli_args.target_runtime] inference_model: FromPretrainedTypeVar | HubModel if is_on_device and isinstance(model, BaseModel): device = hub.Device(cli_args.device, cli_args.device_os) @@ -221,7 +241,7 @@ def demo_model_from_cli_args( compile_job: hub.CompileJob print(f"Compiling on-device model asset for {model.get_model_id()}.") print( - f"Running python -m {export_file} --device {device.name} --target-runtime {target_runtime.name}\n" + f"Running python -m {export_file} --device {device.name} --target-runtime {cli_args.target_runtime.name.lower()}\n" ) export_output = export_module.export_model( device=device.name, @@ -229,7 +249,7 @@ def demo_model_from_cli_args( skip_inferencing=True, skip_downloading=True, skip_summary=True, - dst_runtime=target_runtime.name, + target_runtime=cli_args.target_runtime, ) if len(export_output) == 0 or isinstance(export_output[0], str): @@ -375,14 +395,7 @@ def export_parser( ) if not exporting_compiled_model: # Default runtime for compiled model is fixed for given model - parser.add_argument( - "--dst-runtime", - default="TFLITE", - help="The runtime to export for. Default is TF Lite.", - choices=TargetRuntime._member_names_ - if supports_qnn - else [TargetRuntime.TFLITE.name], - ) + add_target_runtime_arg(parser, help="The runtime for which to export.") # No compilation for compiled models parser.add_argument( "--compile-options", diff --git a/qai_hub_models/utils/base_model.py b/qai_hub_models/utils/base_model.py index e5a3b38e..eea39fac 100644 --- a/qai_hub_models/utils/base_model.py +++ b/qai_hub_models/utils/base_model.py @@ -24,6 +24,9 @@ class TargetRuntime(Enum): TFLITE = 0 QNN = 1 + def __str__(self): + return self.name.lower() + class SourceModelFormat(Enum): ONNX = 0 diff --git a/qai_hub_models/utils/compare.py b/qai_hub_models/utils/compare.py index 13ce8b2e..8d210580 100644 --- a/qai_hub_models/utils/compare.py +++ b/qai_hub_models/utils/compare.py @@ -4,17 +4,13 @@ # --------------------------------------------------------------------- from __future__ import annotations -from typing import Dict, List, NamedTuple, Tuple, Union +from typing import Dict, List, Union import numpy as np +import pandas as pd import torch -class InfenceMetrics(NamedTuple): - psnr: float - shape: Tuple[int, ...] - - def torch_inference( model: torch.nn.Module, sample_inputs: Dict[str, List[np.ndarray]] ) -> List[np.ndarray]: @@ -89,9 +85,42 @@ def compare_psnr( assert psnr > psnr_threshold +def compute_top_k_accuracy(expected, actual, k): + """ + expected, actual: logit / softmax prediction of the same 1D shape. + """ + top_k_expected = np.argpartition(expected.flatten(), -k)[-k:] + top_k_actual = np.argpartition(actual.flatten(), -k)[-k:] + + top_k_accuracy = np.mean(np.isin(top_k_expected, top_k_actual)) + + return top_k_accuracy + + +TOP_K_EXPLAINER = "Match rate between the top {k} classification predictions. 1 indicates perfect match" +PSNR_EXPLAINER = ( + "Peak Signal-to-Noise Ratio (PSNR). >30 dB is typically considered good." +) + +METRICS_FUNCTIONS = dict( + psnr=(compute_psnr, PSNR_EXPLAINER), + top1=( + lambda expected, actual: compute_top_k_accuracy(expected, actual, 1), + TOP_K_EXPLAINER.format(k=1), + ), + top5=( + lambda expected, actual: compute_top_k_accuracy(expected, actual, 5), + TOP_K_EXPLAINER.format(k=5), + ), +) + + def generate_comparison_metrics( - expected: List[np.ndarray], actual: List[np.ndarray] -) -> Dict[int, InfenceMetrics]: + expected: List[np.ndarray], + actual: List[np.ndarray], + names: List[str] | None = None, + metrics: str = "psnr", +) -> pd.DataFrame: """ Compares the outputs of a model run in two different ways. For example, expected might be run on local cpu and actual run on device. @@ -99,13 +128,28 @@ def generate_comparison_metrics( Parameters: expected: List of numpy array outputs computed from a ground truth model. actual: List of numpy array outputs computed from an experimental model. + metrics: comma-separated metrics names, e.g., "psnr,top1,top5" Returns: - A set of metrics representing how close the two sets of outputs are. + DataFrame with range index (0, 1, 2...) and shape, metrics as columns + (e.g., shape | psnr | top1 | top5. """ - metrics = {} + metrics_ls = metrics.split(",") + for m in metrics_ls: + supported_metrics = ", ".join(METRICS_FUNCTIONS.keys()) + if m not in METRICS_FUNCTIONS.keys(): + raise ValueError( + f"Metrics {m} not supported. Supported metrics: {supported_metrics}" + ) + idx = ( + pd.Index(names, name="output_name") + if names + else pd.RangeIndex(stop=len(expected)) + ) + df_res = pd.DataFrame(None, columns=["shape"] + metrics_ls, index=idx) # type: ignore for i, (expected_arr, actual_arr) in enumerate(zip(expected, actual)): - metrics[i] = InfenceMetrics( - compute_psnr(expected_arr, actual_arr), expected_arr.shape - ) - return metrics + loc = i if not names else names[i] + df_res.loc[loc, "shape"] = expected_arr.shape + for m in metrics_ls: + df_res.loc[loc, m] = METRICS_FUNCTIONS[m][0](expected_arr, actual_arr) # type: ignore + return df_res diff --git a/qai_hub_models/utils/config_loaders.py b/qai_hub_models/utils/config_loaders.py index 90b50154..b0d68f0d 100644 --- a/qai_hub_models/utils/config_loaders.py +++ b/qai_hub_models/utils/config_loaders.py @@ -755,6 +755,7 @@ def from_yaml(info_path: str | Path, code_gen_path: str | Path | None = None): OptionalSchema("is_precompiled", default=False): bool, OptionalSchema("no_assets", default=False): bool, OptionalSchema("torchscript_opt", default=[]): list, + OptionalSchema("inference_metrics", default="psnr"): str, } ) ) diff --git a/qai_hub_models/utils/image_processing.py b/qai_hub_models/utils/image_processing.py index c1deebf4..a0ada1fc 100644 --- a/qai_hub_models/utils/image_processing.py +++ b/qai_hub_models/utils/image_processing.py @@ -187,20 +187,28 @@ def resize_pad(image: torch.Tensor, dst_size: Tuple[int, int]): def undo_resize_pad( - image: torch.Tensor, orig_size_wh: Tuple[int, int], padding: Tuple[int, int] + image: torch.Tensor, + orig_size_wh: Tuple[int, int], + scale: float, + padding: Tuple[int, int], ): """ Undos the efffect of resize_pad. Instead of scale, the original size (in order width, height) is provided to prevent an off-by-one size. """ width, height = orig_size_wh - cropped_image = image[ - ..., padding[1] : padding[1] + height, padding[0] : padding[0] + width - ] - rescaled_image = interpolate(cropped_image, size=[height, width], mode="bilinear") + rescaled_image = interpolate(image, scale_factor=1 / scale, mode="bilinear") + + scaled_padding = [int(round(padding[0] / scale)), int(round(padding[1] / scale))] + + cropped_image = rescaled_image[ + ..., + scaled_padding[1] : scaled_padding[1] + height, + scaled_padding[0] : scaled_padding[0] + width, + ] - return rescaled_image + return cropped_image def pil_resize_pad( @@ -216,10 +224,10 @@ def pil_resize_pad( def pil_undo_resize_pad( - image: Image, orig_size_wh: Tuple[int, int], padding: Tuple[int, int] + image: Image, orig_size_wh: Tuple[int, int], scale: float, padding: Tuple[int, int] ) -> Image: torch_image = preprocess_PIL_image(image) - torch_out_image = undo_resize_pad(torch_image, orig_size_wh, padding) + torch_out_image = undo_resize_pad(torch_image, orig_size_wh, scale, padding) pil_out_image = torch_tensor_to_PIL_image(torch_out_image[0]) return pil_out_image diff --git a/qai_hub_models/utils/inference.py b/qai_hub_models/utils/inference.py index ae5d9f6f..f28ca846 100644 --- a/qai_hub_models/utils/inference.py +++ b/qai_hub_models/utils/inference.py @@ -13,6 +13,7 @@ import torch from qai_hub.public_rest_api import DatasetEntries +from qai_hub_models.utils.asset_loaders import ModelZooAssetConfig from qai_hub_models.utils.base_model import BaseModel, SourceModelFormat, TargetRuntime from qai_hub_models.utils.input_spec import InputSpec from qai_hub_models.utils.qai_hub_helpers import ( @@ -287,3 +288,40 @@ def __call__( if len(output_torch) == 1: return output_torch[0] return tuple(output_torch) + + +def get_uploaded_precompiled_model( + model_path: str, + model_name: str, + model_version: str, + model_component: str, + ignore_cached_model: bool = False, +): + """ + Caches pre-compiled model in default asset path to be used in sub-sequence demos. + """ + asset_config = ModelZooAssetConfig.from_cfg() + model_id_path = asset_config.get_local_store_model_path( + model_name, model_version, f"{model_component}_model_id.cached" + ) + + use_cached_model = not ignore_cached_model or os.path.exists(model_id_path) + uploaded_model = None + if use_cached_model: + try: + with open(model_id_path, "r") as model_id_file: + model_id = model_id_file.readline().strip() + print(f"Using previously uploaded model({model_id}) for {model_component}") + uploaded_model = hub.get_model(model_id=model_id) + if uploaded_model is not None: + return uploaded_model + + except Exception: + # Try uploading model instead + use_cached_model = False + + # Upload model on hub + uploaded_model = hub.upload_model(model_path) + with open(model_id_path, "w") as model_id_file: + model_id_file.writelines([f"{uploaded_model.model_id}"]) + return uploaded_model diff --git a/qai_hub_models/utils/printing.py b/qai_hub_models/utils/printing.py index 8c09e9ba..2e20827f 100644 --- a/qai_hub_models/utils/printing.py +++ b/qai_hub_models/utils/printing.py @@ -10,9 +10,10 @@ import qai_hub as hub from prettytable import PrettyTable from qai_hub.client import SourceModelType +from tabulate import tabulate from qai_hub_models.utils.base_model import TargetRuntime -from qai_hub_models.utils.compare import generate_comparison_metrics +from qai_hub_models.utils.compare import METRICS_FUNCTIONS, generate_comparison_metrics from qai_hub_models.utils.config_loaders import QAIHMModelPerf from qai_hub_models.utils.qnn_helpers import is_qnn_hub_model @@ -24,30 +25,35 @@ def print_inference_metrics( inference_result: Dict[str, List[np.ndarray]], torch_out: List[np.ndarray], outputs_to_skip: Optional[List[int]] = None, + metrics: str = "psnr", ) -> None: inference_data = [ np.concatenate(outputs, axis=0) for outputs in inference_result.values() ] output_names = list(inference_result.keys()) - metrics = generate_comparison_metrics(torch_out, inference_data) + df_eval = generate_comparison_metrics( + torch_out, inference_data, names=output_names, metrics=metrics + ) + + def custom_float_format(x): + if isinstance(x, float): + return f"{x:.4g}" + return x + + formatted_df = df_eval.applymap(custom_float_format) + print( f"\nComparing on-device vs. local-cpu inference for {inference_job.name.title()}." ) + print(tabulate(formatted_df, headers="keys", tablefmt="grid")) # type: ignore + print() - table = PrettyTable(align="l") - table.field_names = ["Name", "Shape", "Peak Signal-to-Noise Ratio (PSNR)"] - outputs_to_skip = outputs_to_skip or [] - i = 0 - while i in metrics or i in outputs_to_skip: - if i in outputs_to_skip or np.prod(np.array(metrics[i].shape)) < 5: - table.add_row([output_names[i], metrics[i].shape, "Skipped"]) - i += 1 - continue - table.add_row([output_names[i], metrics[i].shape, f"{metrics[i].psnr:.4g} dB"]) - i += 1 + # Print explainers for each eval metric + for m in df_eval.columns.drop("shape"): # type: ignore + print(f"- {m}:", METRICS_FUNCTIONS[m][1]) - print(table.get_string()) last_line = f"More details: {inference_job.url}" + print() print(last_line) @@ -92,7 +98,7 @@ def print_profile_metrics( details: QAIHMModelPerf.ModelRuntimePerformanceDetails, ): inf_time = details.inference_time_ms - peak_memory_bytes = f"[{round(details.peak_memory_bytes[0] / 1e6)}, {round(details.peak_memory_bytes[1] / 1e6)}]" + peak_memory_mb = f"[{round(details.peak_memory_bytes[0] / 1e6)}, {round(details.peak_memory_bytes[1] / 1e6)}]" num_ops = sum(details.compute_unit_counts.values()) compute_units = [ f"{unit} ({num_ops} ops)" @@ -103,10 +109,10 @@ def print_profile_metrics( ["Device", f"{details.device_name} ({details.device_os})"], ["Runtime", f"{details.runtime.name}"], [ - "Estimated inference time", - "less than 0.1ms" if inf_time < 0.1 else f"{inf_time}", + "Estimated inference time (ms)", + "<0.1" if inf_time < 0.1 else f"{inf_time:.1f}", ], - ["Estimated peak memory usage", f"{peak_memory_bytes}"], + ["Estimated peak memory usage (MB)", f"{peak_memory_mb}"], ["Total # Ops", f"{num_ops}"], ["Compute Unit(s)", " ".join(compute_units)], ] diff --git a/qai_hub_models/utils/quantization.py b/qai_hub_models/utils/quantization.py index 78f87d52..0220849d 100644 --- a/qai_hub_models/utils/quantization.py +++ b/qai_hub_models/utils/quantization.py @@ -9,10 +9,16 @@ import torch from torch.utils.data import DataLoader -from qai_hub_models.utils.asset_loaders import CachedWebAsset, load_torch +from qai_hub_models.utils.asset_loaders import CachedWebDatasetAsset, load_torch -IMAGE_QUANTIZATION_SAMPLES_URL = CachedWebAsset.from_asset_store( - "/quantization/image_quantization_samples.pt" +DATA_ID = "image_quantziation_samples" +DATA_VERSION = 1 + +IMAGE_QUANTIZATION_SAMPLES = CachedWebDatasetAsset( + "https://qaihub-public-assets.s3.us-west-2.amazonaws.com/datasets/image_quantization_samples.pt", + DATA_ID, + DATA_VERSION, + "image_quantization_samples.pt", ) @@ -58,4 +64,5 @@ def get_image_quantization_samples( torch.save(final_tensor, "imagenet_quantization_samples.pt") ``` """ - return load_torch(quantization_samples_path or IMAGE_QUANTIZATION_SAMPLES_URL) + path = IMAGE_QUANTIZATION_SAMPLES.fetch(extract=False) + return load_torch(quantization_samples_path or path) diff --git a/qai_hub_models/utils/quantization_aimet.py b/qai_hub_models/utils/quantization_aimet.py index e70ddc33..40842fa1 100644 --- a/qai_hub_models/utils/quantization_aimet.py +++ b/qai_hub_models/utils/quantization_aimet.py @@ -11,6 +11,7 @@ except (ImportError, ModuleNotFoundError): raise NotImplementedError( "AIMET must be installed to load quantized models. " + "AIMET is only supported on Linux. " "Install AIMET via the instructions here: " "https://quic.github.io/aimet-pages/releases/latest/install/index.html" ) @@ -277,3 +278,15 @@ def _get_input_spec_ts(self, *args, **kwargs) -> InputSpec: """Type safe version of get_input_spec.""" assert isinstance(self, BaseModel) return self.get_input_spec(*args, **kwargs) + + +class HubCompileOptionsInt8Mixin: + def get_hub_compile_options( + self, + target_runtime: TargetRuntime, + other_compile_options: str = "", + ) -> str: + compile_options = super().get_hub_compile_options( # type: ignore + target_runtime, other_compile_options + ) + return compile_options + " --quantize_full_type int8 --quantize_io" diff --git a/qai_hub_models/utils/test_compare.py b/qai_hub_models/utils/test_compare.py new file mode 100644 index 00000000..033628a4 --- /dev/null +++ b/qai_hub_models/utils/test_compare.py @@ -0,0 +1,20 @@ +# --------------------------------------------------------------------- +# Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause +# --------------------------------------------------------------------- +import numpy as np + +from qai_hub_models.utils.compare import compute_top_k_accuracy + + +def test_compute_top_k_accuracy(): + expected = np.array([0.1, 0.2, 0.3, 0.4, 0.5]) + actual = np.array([0.5, 0.4, 0.3, 0.2, 0.1]) + + k = 3 + result = compute_top_k_accuracy(expected, actual, k) + np.testing.assert_allclose(1 / 3, result) + + actual = np.array([0.1, 0.2, 0.3, 0.5, 0.4]) + result = compute_top_k_accuracy(expected, actual, k) + np.testing.assert_allclose(result, 1, atol=1e-3)