---
title: "Test pretrained model using image data"
method: POST
path: "/api/{projectId}/pretrained-model/test-image"
tags: ["Learn"]
---

# Test pretrained model using image data

`POST /api/{projectId}/pretrained-model/test-image`

## Request

- Base URL: `https://studio.edgeimpulse.com/v1`
- URL: `https://studio.edgeimpulse.com/v1/api/{projectId}/pretrained-model/test-image`
- Auth: one of:
  - API key in header `x-api-key`
  - API key in cookie `jwt`
  - API key in header `x-jwt-token`
  - OAuth 2
    - Authorization code: `/v1/oauth/authorize`
    - Client credentials
    - Implicit: `/v1/oauth/authorize`
    - Password
    - Token URL: `/v1/oauth/token`
- TypeScript: <https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/docs/api/:projectId/pretrained-model/test-image/post.ts> (a function with typed inputs; its response is checked against the schema)

Test out a pretrained model (using image data) - upload first via  `uploadPretrainedModel`.
If you want to deploy a pretrained model from the API, see `startDeployPretrainedModelJob`.
This will transform raw image data (e.g. RGB to grayscale, resize) before classifying.
To classify raw features, see `testPretrainedModel`.

## Path parameters

- `projectId` integer, required

## Query parameters

- `impulseId` integer

## Request body

- TestPretrainedModelImagesRequest
  - `imageFileBase64` string, required: A base64 encoded input image file
  - `input` object, required
    - `resizeMode` 'squash' | 'fit-short' | 'fit-long' | 'crop', required: Input images are resized automatically before training and testing, to match the impulse input shape. This determines the resize mode used when the aspect ratio of the input data is different to the aspect ratio of the impulse.
    - `inputScaling` '0..1' | '-1..1' | '-128..127' | '0..255' | 'torch' | 'bgr-subtract-imagenet-mean', required: Normalization that is applied to images. If this is not set then 0..1 is used. "0..1" gives you non-normalized pixels between 0 and 1. "-1..1" gives you non-normalized pixels between -1 and 1. "0..255" gives you non-normalized pixels between 0 and 255. "-128..127" gives you non-normalized pixels between -128 and 127. "torch" first scales pixels between 0 and 1, then applies normalization using the ImageNet dataset (same as `torchvision.transforms.Normalize()`). "bgr-subtract-imagenet-mean" scales to 0..255, reorders pixels to BGR, and subtracts the ImageNet mean from each channel.
  - `model` union, required
    - DeployPretrainedModelModelClassification
      - `modelType` 'classification', required
      - `labels` string[], required
      - `addSoftmax` boolean
    - DeployPretrainedModelModelRegression
      - `modelType` 'regression', required
    - DeployPretrainedModelModelObjectDetection
      - `modelType` 'object-detection', required
      - `labels` string[], required
      - `lastLayer` 'mobilenet-ssd' | 'fomo' | 'yolov2-akida' | 'yolov5' | 'yolov5v5-drpai' | 'yolox' | 'yolov7' | 'yolo-pro' | 'tao-retinanet' | 'tao-ssd' | 'tao-yolov3' | 'tao-yolov4' | 'yolov11' | 'yolov11-abs' | 'paddleocr-detector' | 'qc-face-det-lite' | 'qc-yolox', required
      - `minimumConfidence` number, required: Deprecated: use thresholdValues instead. Threshold for objects (f.e. 0.3).
      - `thresholdValues` object: All configured thresholds for the current model. Valid keys are 'min_score' (object detection models, all but paddleocr-detector); 'min_score_pixel', 'min_score_box', 'unclip_ratio' (paddleocr-detector).
    - DeployPretrainedModelModelFreeform
      - `modelType` 'freeform', required
    - DeployPretrainedModelModelAnomaly
      - `modelType` 'anomaly', required
    - DeployPretrainedModelModelVisualAnomaly
      - `modelType` 'visual-anomaly', required
      - `thresholdValues` object: All configured thresholds for the current model. Valid keys are 'min_anomaly_score' and 'anomaly_scoring_aggregation_method'.

## Response `200`

OK

- TestPretrainedModelResponse
  - `success` boolean, required: Whether the operation succeeded
  - `error` string: Optional error description (set if 'success' was false)
  - `result` object: Classification value per label. For a neural network this will be the confidence, for anomalies the anomaly score.
  - `boundingBoxes` BoundingBoxWithScore[]
    - `label` string, required
    - `x` number, required
    - `y` number, required
    - `width` number, required
    - `height` number, required
    - `score` number, required
  - `freeformResult` object
    - `outputTensors` object[], required
      - `shape` integer[], required
      - `dataType` 'int8' | 'uint8' | 'float32', required
      - `data` number[], required
  - `anomalyResult` AnomalyResult[]: Anomaly scores and computed metrics for visual anomaly detection, one item per window.
    - `boxes` BoundingBoxWithScore[]: For visual anomaly detection. An array of bounding box objects, (x, y, width, height, score, label), one per detection in the image. Filtered by the minimum confidence rating of the learn block.
      - `label` string, required
      - `x` number, required
      - `y` number, required
      - `width` number, required
      - `height` number, required
      - `score` number, required
    - `scores` array[]: 2D array of shape (n, n) with raw anomaly scores for visual anomaly detection, where n can be calculated as ((1/8 of image input size)/2 - 1). The scores corresponds to each grid cell in the image's spatial matrix.
      - number[]
    - `meanScore` number: Mean value of the scores.
    - `maxScore` number: Maximum value of the scores.

---

[API](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api.md) - [All operations](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/llms.txt) - [OpenAPI document](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/revisions/e2a976d38427?raw)
