---
title: "nv-grounding-dino"
publisher: "nvidia"
type: "endpoint"
updated: "2025-03-26T16:21:21.125Z"
description: "Grounding dino is an open vocabulary zero-shot object detection model."
canonical: "https://build.nvidia.com/nvidia/nv-grounding-dino"
---

# Pretrained Grounding DINO with Commercial License

## Description <a class="anchor" name="description"></a>

Open vocabulary object detection is a computer vision technique that can detect one or multiple objects in a frame based on the text input. Object detection recognizes the individual objects in an image and places bounding boxes around the object. This model card contains pre-trained weights for the [Grounding DINO](https://arxiv.org/abs/2303.05499) object detection networks pretrained on the commercial dataset. Note that the model in this model card can be used for commercial purpose.

## References <a class="anchor" name="references"></a>

- Zhang, H., Li, F., Liu, S., Zhang, L., Su, H., Zhu, J., Ni, L., Shum, H.: DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection.
- Ziu, S., Zeng, Z., Ren, T., Li, F., Zhang, H., Yang, J., Li, C., Yang, J., Su, H., Zhu, J., Zhang, L.: Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection. 
- Devlin, J., Chang, M., Lee, K., Toutanova, K.: BERT: PRe-training of Deep Bidirectional Transformers for Language Understanding.
- Liu, Z., Lin, Y., Cao, Y., Hu, H., Wei, Y., Zhang, Z., Lin, S., Guo, B.: Swin Transformer: Hierarchical Vision Transformer using Shifted Windows.

## License <a class="anchor" name="license"></a>

The licenses to use this model is covered by the Model EULA. By downloading the unpruned or pruned version of the model, you accept the terms and conditions of these [licenses](https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/)

## Model Architecture <a class="anchor" name="ddetr_based_object_detection"></a>

**Architecture Type:** Transformer-based Network Architecture

**Network Architecture**
- Backbone: Window attention based Transformers called Swin-Tiny and BERT-Base text encoder.
- Encoder: 6 layers of Multi-headed attention with deformable attention layers.
- Decoders: 6 layers of Multi-headed attention with deformable attention layers.

**More Details**
- The models in this instance are object detectors that take RGB images and list of phrases as input and produce bounding boxes and classes as output. More specifically, this model was trained with [Swin-Tiny backbone](https://arxiv.org/pdf/2103.14030) that was trained using a supervised manner on NVIDIA proprietary data called NVImageNetv2, which allows commercial usage. In addition, BERT-Base was used as the starting weight for text tower. Finally, Grounding DINO was trained end-to-end on about 1.8M images that were collected from publicly available datasets. Note that we ensured that all the raw images used during training have commercial licenses to ensure safe commercial usage.

### Input

**Input Type(s):** Image and list of captions of tokenized through HuggingFace <br>
**Input Format(s):** Red, Green, Blue (RGB) and tokenized inputs. Can support any input resolution and images do not need any additional pre-processing (e.g. alpha channels or bits) <br>
**Input Parameters:** Multiple dimensions. See below for detailed input shapes <br>
**Other Properties Related to Input:** <br>
- `inputs`: B X 3 X 544 X 960 (Batch Size x Channel x Height x Width)
- `input_ids`: B x 256 (Batch Size x Max Token Length )
- `attention_mask`: B x 256 (Batch Size x Max Token Length )
- `position_ids`: B x 256 (Batch Size x Max Token Length )
- `token_type_ids`: B x 256 (Batch Size x Max Token Length )
- `text_token_mask`: B x 256 x 256 (Batch Size x Max Token Length x Max Token Length)
- Because ONNX / TensorRT can't take string as input, we've offloaded tokenizer outside of the model graph. See [TAO-Deploy](https://github.com/NVIDIA/tao_deploy) repo on running tokenization through HuggingFace.

<img align="center" title="building change" src="https://github.com/vpraveen-nv/model_card_images/blob/main/cv/purpose_built_models/grounding_dino/commercial_swint_gdino.png?raw=true" width="1400" >

### Output

**Output Type(s):** Bounding Boxes and Confidence Scores for each detected object in the input image. <br>
**Output Formats:** One Dimensional (1D), Two Dimensional (2D) vectors <br>
**Other Properties Related to Output:** <br>
- `pred_logits`: B x 900 (Batch Size x Number of Queries)
- `pred_boxes`: B x 900 x 4 (Batch Size x Number of Queries x Coordinates in `cxcywh` format)

## Software Integration
**Runtime Engine(s):** 
* TAO - 5.5.0 <br>

**Supported Hardware Architecture(s):** <br>
* NVIDIA Ampere <br>
* NVIDIA Jetson  <br>
* NVIDIA Hopper <br>
* NVIDIA Lovelace <br>
* NVIDIA Pascal <br>
* NVIDIA Turing <br>
* NVIDIA Volta <br>

**Supported Operating System(s):** <br>
* Linux <br>
* Linux 4 Tegra <br>

## Model Versions

- **grounding_dino_swin_tiny_commercial_trainable_v1.0** - Pre-trained Swin-Tiny Grounding DINO model for finetune.
- **grounding_dino_swin_tiny_commercial_deployable_v1.0** - Swin-Tiny Grounding DINO model deployable.

## Training & Evaluation: 

This model was trained using the `grounding_dino` entrypoint in TAO. The training algorithm optimizes the network to minimize the localization and contrastive embedding loss between text and visual features.

## Using this Model <a class="anchor" name="how_to_use_this_model"></a>

These models need to be used with NVIDIA hardware and software. For hardware, the models can run on any NVIDIA GPU including NVIDIA Jetson devices. These models can only be used with [Train Adapt Optimize (TAO) Toolkit](https://developer.nvidia.com/tao-toolkit), or [TensorRT](https://developer.nvidia.com/tensorrt).

The intended use for these models is detecting objects in a color (RGB) image. The model can be used to detect objects from photos and videos by using appropriate video or image decoding and pre-processing.

These models are intended for training and fine-tune with the TAO Toolkit and your datasets for object detection. High-fidelity models can be trained with new use cases. A Jupyter Notebook is available as a part of the pytorch [TAO container](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/tao/containers/tao-toolkit/tags)  and can be used to re-train.

The models are also intended for easy edge deployment using TensorRT.

## Training Dataset <a class="anchor" name="training_data"></a>

### Training Data <a class="anchor" name="training_data"></a>

Grounding DINO was pretrained on wide range of commercial datasets where the annotations were either human generated or pseudo-labeled. The model was trained on 1,815,237 images and 14,794,974 instances of both object detection (OD) and grounding annotations. Please refer to below section for details of every dataset used to train Grounding DINO.

| Dataset                        | Data Collection Method by dataset | Labeling Method by dataset | # of Images|# of Annotations|
|--------------------------------|-----------------------------------|----------------------------|------------|----------------|
| Subset of OpenImagesv5         | Unknown   | Automated. Pseudo-labeled raw images with Objects365 trained CO-DETR. |803,826   | 7,345,546|
| Localized Narrative OpenImages | Unknown   | Automated. Pseudo-labeled raw images and global captions with Grounding DINO. | 670,553   | 6,098,908| 
| Subset of LVIS                 | Unknown   | Human-labeled (only contains commercial subset).    | 30,740        | 391,840        |
| Subset of Mixed Grounding      | Unknown   | Human-labeled (only contains commercial subset).    | 150,668       | 777,178        | 
| Subset of RefCOCO              | Unknown   | Human-labeled (only contains commercial subset).    | 36,459        | 36,459         | 
| Subset of RefCOCO+             | Unknown   | Human-labeled (only contains commercial subset).    | 36,302        | 36,302         | 
| Subset of RefCOCOg             | Unknown   | Human-labeled (only contains commercial subset).    | 23,718        | 23,718         | 
| Subset of gRefCOCO             | Unknown   | Human-labeled (only contains commercial subset).    | 62,971        | 85,023         | 

## Evaluation Data <a class="anchor" name="evaluation_data"></a>

**Data Collection Method by dataset:** <br>
- Unknown <br>

**Labeling Method by dataset:** <br>
- Human. <br>

**Properties:**  <br>
- COCO validation dataset with 5,000 images.

### Methodology and KPI

The key performance indicator is the mean average precision (mAP), following the standard evaluation protocol for object detection. The KPI for the evaluation data are: 

|model|precision|mAP|mAP50|mAP75|mAPs|mAPm|mAPl|
|---|---|---|---|---|---|---|---|
|grounding_dino_swin_tiny|BF16|46.1|59.9|51.0|30.5|49.3|60.8|

## Model Limitation <a class="anchor" name="model limitation"></a>

Grounding DINO was trained on images collected from the web and text data of everyday noun phrases. The model might not perform well on different data distributions. Conducting further fine-tuning on the target domain is recommended to get a higher mAP.

## Technical Blogs <a class="anchor" name="technical_blogs"></a>

- [Train like a ‘pro’ without being an AI expert using TAO AutoML](https://developer.nvidia.com/blog/training-like-an-ai-pro-using-tao-automl/)
- [Create Custom AI models using NVIDIA TAO Toolkit with Azure Machine Learning ](https://developer.nvidia.com/blog/creating-custom-ai-models-using-nvidia-tao-toolkit-with-azure-machine-learning/)
- [Developing and Deploying AI-powered Robots with NVIDIA Isaac Sim and NVIDIA TAO](https://developer.nvidia.com/blog/developing-and-deploying-ai-powered-robots-with-nvidia-isaac-sim-and-nvidia-tao/)
- Learn endless ways to adapt and supercharge your AI workflows with TAO - [Whitepaper](https://developer.nvidia.com/tao-toolkit-usecases-whitepaper/1-introduction)
- [Customize Action Recognition with TAO and deploy with DeepStream](https://developer.nvidia.com/blog/developing-and-deploying-your-custom-action-recognition-application-without-any-ai-expertise-using-tao-and-deepstream/)
- Read the two-part blog on training and optimizing 2D body pose estimation model with TAO - [Part 1](https://developer.nvidia.com/blog/training-optimizing-2d-pose-estimation-model-with-tao-toolkit-part-1)  |  [Part 2](https://developer.nvidia.com/blog/training-optimizing-2d-pose-estimation-model-with-tao-toolkit-part-2)
- Learn how to train a [real-time License plate detection and recognition app](https://developer.nvidia.com/blog/creating-a-real-time-license-plate-detection-and-recognition-app) with TAO and DeepStream.
- Model accuracy is extremely important; learn how you can achieve [state of the art accuracy for classification and object detection models](https://developer.nvidia.com/blog/preparing-state-of-the-art-models-for-classification-and-object-detection-with-tao-toolkit/) using TAO.

## Suggested Reading <a class="anchor" name="suggested_reading"></a>

- More information on TAO Toolkit and pre-trained models can be found at the [NVIDIA Developer Zone](https://developer.nvidia.com/tao-toolkit)
- Refer to the [TAO documentation](https://docs.nvidia.com/tao/tao-toolkit/index.html)
- Read the [TAO Toolkit Quick Start Guide](https://docs.nvidia.com/tao/tao-toolkit/index.html) and [release notes](https://docs.nvidia.com/tao/tao-toolkit/text/release_notes.html).
- If you have any questions or feedback, please refer to the discussions on the [TAO Toolkit Developer Forums](https://forums.developer.nvidia.com/c/accelerated-computing/intelligent-video-analytics/tao-toolkit/17)
- Deploy your models for video analytics application using the [DeepStream SDK](https://developer.nvidia.com/deepstream-sdk).
- Deploy your models in [Riva](https://developer.nvidia.com/riva) for ConvAI use case.

## Ethical Considerations <a class="anchor" name="ethical_ai"></a>

NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications.  When downloaded or used in accordance with our terms of service, developers should work with their supporting model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.  For more detailed information on ethical considerations for this model, please see the Model Card++ Promise and the Explainability, Bias, Safety & Security, and Privacy Subcards. Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).

## Bias

| Field | Response |
| -- | -- |
|Participation considerations from adversely impacted groups [(protected classes)](https://www.senate.ca.gov/content/protected-classes) in model design and testing: | None of the Above |
| Measures taken to mitigate against unwanted bias: | No measures taken to mitigate against unwanted bias.|

## Explainability

| Field | Response |
| -- | -- |
| Intended Application(s) & Domain(s): | Detecting Objects |
| Model Type: | Object Detection |
| Intended Users: | The model is intended for developers that build multimodal object detection application. |
| Output: | Bounding Box, Confidence Scores, and Noun Phrases |
| Describe how the model works: | Extracts features from provided images using provided list of nouns. |
| Technical Limitations: | The model may have difficulties in non-Flickr style data like medical, satellite, and industrial data. |
| Verified to have met prescribed NVIDIA standards: | Yes |
| Performance Metrics: | Mean Average Precision (mAP) |
| Licensing: | [EULA](https://commercialtype.com/eula) |

## Privacy

| Field | Response |
| -- | -- |
| Generatable or reverse engineerable personally-identifiable information (PII)? | None |
| Protected classes used to create this model? | Not Applicable (No PII) |
| Was consent obtained for any PII used? | Not Applicable (No PII) |
| How often is dataset reviewed? | 	Before Release |
| Is a mechanism in place to honor data subject right of access or deletion of personal data? | No |
| If PII collected for the development of the model, was it collected directly by NVIDIA? |Not Applicable |
| If PII collected for the development of the model by NVIDIA, do you maintain or have access to disclosures made to data subjects?	| No |
| If PII collected for the development of this AI model, was it minimized to only what was required? | Not Applicable |
| Is there provenance for all datasets used in training? | No |
| Does data labeling (annotation, metadata) comply with privacy laws? | Yes |
| Is data compliant with data subject requests for data correction or removal, if such a request was made? | No, not possible with externally-sourced data.
|
| Applicable NVIDIA Privacy Policy	| [https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/](https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/) |

## Safety & Security

| Field | Response |
| -- | -- |
| Model Application(s): | Object Detection (General Purpose) |
| Describe the life-critical application (if present). | None: Not within Operational Design Domain |
| Use Case Restrictions: | Abide by [https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/"](https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/)  |
| Describe access restrictions (if any): | The Principle of least privilege (PoLP) is applied limiting access for dataset generation and model development.  |

## Prototype

```python
import os
import sys
import uuid
import zipfile
import time
import requests

nvai_url="https://ai.api.nvidia.com/v1/cv/nvidia/nv-grounding-dino"
nvai_polling_url = "https://api.nvcf.nvidia.com/v2/nvcf/pexec/status/"
header_auth = f"Bearer {os.getenv('NVIDIA_PERSONAL_API_KEY')}"

UPLOAD_ASSET_TIMEOUT = 300 # Timeout (in secs) to upload asset
MAX_RETRIES = 5 # Max num of retries while polling
DELAY_BTW_RETRIES = 1 # adding 1s delay between each polls

def _upload_asset(input, description):
assets_url = "https://api.nvcf.nvidia.com/v2/nvcf/assets"

headers = {
"Authorization": header_auth,
"Content-Type": "application/json",
"accept": "application/json",
}

s3_headers = {
"x-amz-meta-nvcf-asset-description": description,
"content-type": "video/mp4",
}

payload = {"contentType": "video/mp4", "description": description}

response = requests.post(assets_url, headers=headers, json=payload, timeout=60)

response.raise_for_status()

asset_url = response.json()["uploadUrl"]
asset_id = response.json()["assetId"]

response = requests.put(
asset_url,
data=input,
headers=s3_headers,
timeout=UPLOAD_ASSET_TIMEOUT,
)

response.raise_for_status()
return uuid.UUID(asset_id)

if __name__ == "__main__":
"""Uploads a video or image of your choosing to the NVCF API and sends a
request to the Grounding Dino Object Detection model. The response is saved to a
local directory.

Note: You must set up an environment variable, NGC_PERSONAL_API_KEY.
"""

if len(sys.argv) != 4:
print("Usage: python test.py <prompt> <input_video> <output_dir>")
sys.exit(1)

asset_id = _upload_asset(open(sys.argv[2], "rb"), "Input Video")

inputs = { "model": "Grounding-Dino",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": f"{sys.argv[1]}"
},
{
"type": "media_url",
"media_url": {
"url": f"data:image/jpeg;asset_id,{asset_id}"
}
}
]
}
],
"threshold": 0.3
}

asset_list = f"{asset_id}"

headers = {
"Content-Type": "application/json",
"NVCF-INPUT-ASSET-REFERENCES": asset_list,
"NVCF-FUNCTION-ASSET-IDS": asset_list,
"Authorization": header_auth,
}

response = requests.post(nvai_url, headers=headers, json=inputs)

if response.status_code == 200: # evaluation complete, output video ready
with open(f"{sys.argv[3]}.zip", "wb") as out:
out.write(response.content)
with zipfile.ZipFile(f"{sys.argv[3]}.zip", "r") as z:
z.extractall(sys.argv[3])

elif response.status_code == 202: # pending evaluation
print("Pending evaluation ...")
nvcf_reqid = response.headers['NVCF-REQID']
nvai_polling_url = nvai_polling_url + nvcf_reqid

# Polling to check if the response is ready
while( MAX_RETRIES ):
print(f'Polling ...')
headers_polling = { "accept": "application/json", "Authorization": header_auth }
response_polling = requests.get(nvai_polling_url, headers=headers_polling)
if response_polling.status_code == 202: # evaluation pending
print('Result is not yet ready.')
MAX_RETRIES -= 1
time.sleep(DELAY_BTW_RETRIES)
continue
elif response_polling.status_code == 200: # evaluation complete, output video ready
print('Result ready!')
with open(f"{sys.argv[3]}.zip", "wb") as out:
out.write(response_polling.content)
break
else:
print(f"Unexpected response status: {response_polling.status_code}")

with zipfile.ZipFile(f"{sys.argv[3]}.zip", "r") as z:
z.extractall(sys.argv[3])

print(f"Output saved to {sys.argv[3]}")
print(os.listdir(sys.argv[3]))
```

```javascript
const fs = require('fs');
const decompress = require('decompress');
const { setTimeout } = require('timers/promises');

const nvai_url="https://ai.api.nvidia.com/v1/cv/nvidia/nv-grounding-dino"
const nvai_polling_url = "https://api.nvcf.nvidia.com/v2/nvcf/pexec/status/"
const header_auth = `Bearer ${process.env.NVIDIA_PERSONAL_API_KEY}`;

// Constants for polling
const MAX_RETRIES = 5;
const DELAY_BTW_RETRIES = 1000; // in milliseconds (1 second)

async function _upload_asset(input, description) {
const assets_url = "https://api.nvcf.nvidia.com/v2/nvcf/assets";

const headers = {
"Authorization": header_auth,
"Content-Type": "application/json",
"accept": "application/json",
};

const s3_headers = {
"x-amz-meta-nvcf-asset-description": description,
"content-type": "video/mp4",
};

const payload = {
"contentType": "video/mp4",
"description": description
};

const response = await fetch(
assets_url, { method: 'POST', body: JSON.stringify(payload), headers: headers }
);

const data = await response.json();

const asset_url = data["uploadUrl"];
const asset_id = data["assetId"];

const fileData = fs.readFileSync(input);

await fetch(
asset_url,
{ method: 'PUT', body: fileData, headers: s3_headers }
);

return asset_id.toString();
}

(async () => {
if (process.argv.length != 5) {
console.log("Usage: node test.js <prompt> <input_video> <output_dir>");
process.exit(1);
}

// Upload specified user asset
const asset_id = await _upload_asset(`${process.argv[3]}`, "Input Video");

// Metadata for the request
const inputs =  { "model": "Grounding-Dino",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": `${process.argv[2]}`
},
{
"type": "media_url",
"media_url": {
"url": `data:image/jpeg;asset_id,${asset_id}`
}
}
]
}
],
"threshold": 0.3
}
const asset_list = asset_id;
const headers = {
"Content-Type": "application/json",
"NVCF-INPUT-ASSET-REFERENCES": asset_list,
"NVCF-FUNCTION-ASSET-IDS": asset_list,
"Authorization": header_auth
};

// Make the request to nvcf
const response = await fetch(nvai_url, {
method: 'POST', body: JSON.stringify(inputs), headers: headers
});

if (response.status === 200) {
// Evaluation complete, output ready
// Gather the binary response data
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);

const zipname = `${process.argv[4]}.zip`;
fs.writeFileSync(zipname, buffer);

// Unzip the response synchronously
await decompress(zipname, process.argv[4]);

// Log the output directory and its contents
console.log(`Response saved to ${process.argv[4]}`);
console.log(fs.readdirSync(process.argv[4]));

} else if (response.status === 202) {
// Pending evalutation
console.log("Pending evaluation ...");
const nvcf_reqid = response.headers.get('NVCF-REQID');
let retries = MAX_RETRIES;

while (retries > 0) {
console.log('Polling ...');
const pollingResponse = await fetch(`${nvai_polling_url}${nvcf_reqid}`, {
method: 'GET', headers: {
"accept": "application/json",
"Authorization": header_auth
}
});

if (pollingResponse.status === 202) {
// Evaluation still pending
console.log('Result is not yet ready.');
retries -= 1;
await setTimeout(DELAY_BTW_RETRIES);
} else if (pollingResponse.status === 200) {
// Evaluation complete, output ready
console.log('Result ready!');
const arrayBuffer = await pollingResponse.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
const zipname = `${process.argv[4]}.zip`;
fs.writeFileSync(zipname, buffer);

// Unzip the response synchronously
await decompress(zipname, process.argv[4]);

// Log the output directory and its contents
console.log(`Response saved to ${process.argv[4]}`);
console.log(fs.readdirSync(process.argv[4]));
break;
} else {
console.error('Unexpected response status:', pollingResponse.status);
break
}

if (retries === 0) {
console.error('Max retries reached. Evaluation not completed.');
}
}
} else {
console.error('Unexpected response status:', response.status);
}

})();
```

```bash
#!/bin/bash

set -e

# Check arguments
if [ "$#" -ne 3 ]; then
echo "Usage: ./test.sh <prompt> <input_video> <output_dir>"
exit 1
fi

# Constants
MAX_RETRIES=5
DELAY_BTW_RETRIES=1 # in seconds

header_auth="Bearer $NVIDIA_PERSONAL_API_KEY"
assets_url="https://api.nvcf.nvidia.com/v2/nvcf/assets"

nvai_url="https://ai.api.nvidia.com/v1/cv/nvidia/nv-grounding-dino"
nvai_polling_url="https://api.nvcf.nvidia.com/v2/nvcf/pexec/status/"

function upload_asset {
local input=$1
local description=$2

response=$(curl -s -X POST $assets_url \
-H "Authorization: ${header_auth}" \
-H "Content-Type: application/json" \
-H "accept: application/json" \
-d '{"contentType": "video/mp4", "description": "'"${description}"'"}')

asset_url=$(echo ${response} | jq -r .uploadUrl)
asset_id=$(echo ${response} | jq -r .assetId)

curl -s -X PUT -H "x-amz-meta-nvcf-asset-description: ${description}" -H "content-type: video/mp4" \
--data-binary "@${input}" ${asset_url}

echo ${asset_id}
}

asset_id=$(upload_asset "$2" "Input Video")

inputs='{"model": "Grounding-Dino", "messages": [{"role": "user", "content": [{"type": "text", "text": "'"${1}"'"}, {"type": "media_url", "media_url": {"url": "data:image/jpeg;asset_id,'"${asset_id}"'" }}]}], "threshold": 0.3}'
asset_list="${asset_id}"

# The response will include a location header that curl doesn't trivially
# redirect to due to its complexity. We need to extract the location header
# and then download the file from that location.
response=$(curl -D - -s -w "%{http_code}" -X POST $nvai_url \
-H "Content-Type: application/json" \
-H "NVCF-INPUT-ASSET-REFERENCES: ${asset_list}" \
-H "NVCF-FUNCTION-ASSET-IDS: ${asset_list}" \
-H "Authorization: ${header_auth}" \
-d "${inputs}")

# Extracting status code
status_code=$(echo "$response" | grep HTTP | awk '{print $2}')
# Remove any newlines, carriage returns, spaces, quotes, and commas from the location header
location=$(echo "$response" | grep -i location | awk '{print $2}' |
tr -d '\n' | tr -d '\r' | tr -d ' ' | tr -d '"' | tr -d ',')

if [ -n "$location" ]; then
# location non empty, Evaluation complete, download the file
curl -s "$location" -o "$3.zip"
# Unzip the file
unzip -q "$3.zip" -d "$3"
echo "Response saved to $3.zip"
echo $(ls "$3")
exit 0
elif [ -z "$location" ]; then
# location empty, Pending evaluation, need polling
echo "Pending evaluation ..."

retries=$MAX_RETRIES
while [ $retries -gt 0 ]; do
echo "Polling ..."
nvcf_reqid=$(echo "$response" | grep -i nvcf-reqid | awk '{print $2}' |
tr -d '\n' | tr -d '\r' | tr -d ' ' | tr -d '"' | tr -d ',')
polling_url="${nvai_polling_url}${nvcf_reqid}"
polling_response=$(curl -D - -s -w "%{http_code}" -X GET $polling_url \
-H "accept: application/json" \
-H "Authorization: ${header_auth}")

# Extracting location
polling_location=$(echo "$polling_response" | grep -i location | awk '{print $2}' |
tr -d '\n' | tr -d '\r' | tr -d ' ' | tr -d '"' | tr -d ',')

if [ -z "$polling_location" ]; then
echo "Result is not yet ready."
retries=$((retries - 1))
sleep $DELAY_BTW_RETRIES
elif [ -n "$polling_location" ]; then
echo "Result ready!"
curl -s "$polling_location" -o "$3.zip"
unzip -q "$3.zip" -d "$3"
echo "Response saved to $3.zip"
echo $(ls "$3")
exit 0
else
echo "Unexpected response status: $polling_status"
exit 1
fi
done

if [ $retries -eq 0 ]; then
echo "Max retries reached. Evaluation not completed."
exit 1
fi
else
echo "Unexpected response status: $status_code"
exit 1
fi
```