# Quick start guide

This section provides a complete workflow for running inference on Cloud AI platforms using a Vision Transformer (ViT) model for classifying images. It shows you how to do the following:

- Load a pre-trained ViT model.
- Convert the model to ONNX and compile it for the AIC100.
- Perform inference on an example image to obtain a prediction.

## Prerequisites

- Python 3.10+
- Operational and properly configured Dragonwing AI On-Prem Appliance. See [Appliance setup overview](https://docs.qualcomm.com/doc/80-92111-1/topic/appliance-setup-overview.html) for information on how to verify the appliance box setup.
- Internet connectivity to download the pre-trained ViT model and the example image.

## Run a sample model on Qualcomm Cloud AI Platforms

Run this example on the host Linux system where the Cloud AI SDK is installed and the AI 100 device is accessible.

1. Create a virtual environment, install the qaic wheel file from a local path, and install the necessary libraries.

python3.10 -m venv vit_env
        source vit_env/bin/activate
        
        pip3 install pip -U
        pip3 install /opt/qti-aic/dev/lib/x86_64/qaic-0.0.1-py3-none-any.whl
        pip3 install requests numpy Pillow onnx==1.16.0 transformers==4.46.3
        pip3 install torch@https://download.pytorch.org/whl/cpu/torch-2.4.1%2Bcpu-cp310-cp310-linux_x86_64.whl
        Copy to clipboard
2. Import Python libraries for machine learning and system operations.

import os, shutil, sys, requests, torch, numpy, PIL
        from transformers import ViTForImageClassification, ViTImageProcessor
        import qaic
        Copy to clipboard
3. Load the Vision Transformer (ViT) model and its image processing tools. The ViT model is for image classification.

# Choose the Vision Transformers model for classifying images and its image input preprocessor
        model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
        processor = ViTImageProcessor.from_pretrained('google/vit-base-patch16-224')
        Copy to clipboard
4. Prepare the pre-trained model and covert it to ONNX for the best performance and accuracy. Exporting the model in ONNX format is strongly recommended for operator support.

dummy_input = torch.randn(1, 3, 224, 224)       # Batch, channels, height, width
        
        torch.onnx.export(model,                        # PyTorch model
                     dummy_input,               # Input tensor
                     'model.onnx',              # Output file
                     export_params = True,      # Export the model parameters
                     input_names   = ['input'], # Input tensor names
                     output_names  = ['output'] # Output tensor names
                     )
        Copy to clipboard
5. Compile the model with the [qaic-exec command-line tool](https://docs.qualcomm.com/doc/80-99100-3/topic/index_model-compilation.html#reference-to-compile-the-model). This quickstart issues the command from Python. If you have already compiled the model and prepared the binary and inputs, skip straight to the [Run the Model](https://docs.qualcomm.com/doc/80-99100-3/topic/index_Quick-Start-Guide.html#run-the-model) step.

aic_binary_dir = 'aic-binary-dir'
        
        if os.path.exists(aic_binary_dir):
            shutil.rmtree(aic_binary_dir)
        
        cmd = '/opt/qti-aic/exec/qaic-exec -aic-hw -aic-hw-version=2.0 -compile-only -convert-to-fp16 \
        -aic-num-cores=4 -m=model.onnx -onnx-define-symbol=batch_size,1 -aic-binary-dir=' + aic_binary_dir
        os.system(cmd)
        Copy to clipboard
6. Get an example image for processing.

url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
        image = PIL.Image.open(requests.get(url, stream=True).raw)
        Copy to clipboard
7. Create the AIC100 session, provide path to the compiled model binary, and prepare the inputs and outputs.

# Create the AIC100 session and prepare inputs and outputs
        
        vit_sess = qaic.Session(model_path= aic_binary_dir+'/programqpc.bin',
        num_activations=1)
        
        inputs = processor(images=image, return_tensors='pt')
        input_shape, input_type = vit_sess.model_input_shape_dict['input']
        input_data = inputs['pixel_values'].numpy().astype(input_type)
        input_dict = {'input': input_data}
        
        output_shape, output_type = vit_sess.model_output_shape_dict['output']
        Copy to clipboard

8. Load the compiled model and execute it on the AIC100.

# Run model on AIC100
        
        vit_sess.setup() # Load the model to the device.
        output = vit_sess.run(input_dict) # Execute on AIC100 now.
        Copy to clipboard
9. Find the highest probability among all classes and print the prediction.

# Obtain the prediction by finding the highest probability among all classes
        
        logits = numpy.frombuffer(output['output'], dtype=output_type).reshape(output_shape)
        predicted_class_idx = logits.argmax(-1).item()
        print('Predicted class:', model.config.id2label[predicted_class_idx])
        Copy to clipboard

The expected output is similar to the following:

> 
> 
> $ sudo python quickstart.py
>     
>     Reading ONNX Model from model.onnx
>     Compile started ...............
>     Compiling model with FP16 precision.
>     Generated binary is present at aic-binary-dir
>     Predicted class: Egyptian cat
>     Copy to clipboard

## Full quickstart code

For your convenience, this section provides all of the code from the previous examples in one block.

> 
> 
> # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
>     # SPDX-License-Identifier: BSD-3-Clause-Clear
>     
>     # Import relevant libraries
>     import os, shutil, sys, requests, torch, numpy, PIL
>     from transformers import ViTForImageClassification, ViTImageProcessor
>     import qaic
>     
>     # Choose the Vision Transformers model for classifying images and its image input preprocessor
>     model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
>     processor = ViTImageProcessor.from_pretrained('google/vit-base-patch16-224')
>     
>     dummy_input = torch.randn(1, 3, 224, 224)       # Batch, channels, height, width
>     
>     torch.onnx.export(model,                    # PyTorch model
>                      dummy_input,               # Input tensor
>                      'model.onnx',              # Output file
>                      export_params = True,      # Export the model parameters
>                      input_names   = ['input'], # Input tensor names
>                      output_names  = ['output'] # Output tensor names
>                      )
>     
>     aic_binary_dir = 'aic-binary-dir'
>     
>     if os.path.exists(aic_binary_dir):
>         shutil.rmtree(aic_binary_dir)
>     
>     cmd = '/opt/qti-aic/exec/qaic-exec -aic-hw -aic-hw-version=2.0 -compile-only -convert-to-fp16 \
>           -aic-num-cores=4 -m=model.onnx -onnx-define-symbol=batch_size,1 -aic-binary-dir=' + aic_binary_dir
>     os.system(cmd)
>     
>     url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
>     image = PIL.Image.open(requests.get(url, stream=True).raw)
>     
>     # Create the AIC100 session and prepare inputs and outputs
>     
>     vit_sess = qaic.Session(model_path= aic_binary_dir+'/programqpc.bin',
>        num_activations=1)
>     
>     inputs = processor(images=image, return_tensors='pt')
>     input_shape, input_type = vit_sess.model_input_shape_dict['input']
>     input_data = inputs['pixel_values'].numpy().astype(input_type)
>     input_dict = {'input': input_data}
>     
>     output_shape, output_type = vit_sess.model_output_shape_dict['output']
>     
>     ## Access the hardware
>     vit_sess.setup() # Load the model to the device.
>     output = vit_sess.run(input_dict) # Execute on AIC100 now.
>     
>     ## Obtain the prediction by finding the highest probability among all classes.
>     logits = numpy.frombuffer(output['output'], dtype=output_type).reshape(output_shape)
>     predicted_class_idx = logits.argmax(-1).item()
>     print('Predicted class:', model.config.id2label[predicted_class_idx])
>     Copy to clipboard

## Next steps

- See [Cloud AI SDKs](https://docs.qualcomm.com/doc/80-99100-3/topic/index_Getting-Started.html)  for a Cloud AI SDK overview.
- See [inference workflow](https://docs.qualcomm.com/doc/80-99100-3/topic/index_Inference-Workflow.html#reference-to-inference-workflow) for more details on deploying pre-trained modes using the ONNX and PyTorch workflows.

Last Published: May 01, 2026

[Previous Topic
Cloud AI SDK overview](https://docs.qualcomm.com/bundle/publicresource/80-99100-3/topics/index_Getting-Started.md) [Next Topic
Verify setup](https://docs.qualcomm.com/bundle/publicresource/80-99100-3/topics/verify-setup.md)