> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload Model Predictions

> [!NOTE]
>
> **[Click for Python SDK](https://docs.nucleus.scale.com/en/latest/api/nucleus/index.html#nucleus.Dataset.upload_predictions)**
>
> ```
> Dataset.upload_predictions(
>     model: Model,
>     predictions: List[Prediction],
>     update: bool,
>     asynchronous: bool
> ) -> Union[dict, AsyncJob]
> ```

After inference is complete, you'll want to pack the model outputs into the format Nucleus requires to begin computation on your model's performance.

This JSON schema is almost exactly the same as that of [Annotations](https://api-reference.scale.com/docs/nucleus/api-reference/annotations-overview), but predictions also take in optional `confidence` and `class_pdf` key-value pairs.

## Definition: `BoxGeometry`

| Key | Type | Description |
| - | - | - |
| `x` | float (**required**) | The distance, in pixels, between the left border of the bounding box and the left border of the image. |
| `y` | float (**required**) | The distance, in pixels, between the top border of the bounding box and the top border of the image. |
| `width` | float (**required**) | The width in pixels of the annotation. |
| `height` | float (**required**) | The height in pixels of the annotation. |

## Definition: `Point2D`

| Key | Type | Description |
| - | - | - |
| `x` | float (**required**) | The distance, in pixels, between the left border of the image and the point. |
| `y` | float (**required**) | The distance, in pixels, between the top border of the image and the point. |

## Definition: `PolygonGeometry`

| Key | Type | Description |
| - | - | - |
| `vertices` | array of [`Point2D`](#definition-point2d) | Array of `Point` objects that represent vertices of the polygon. |

## Definition: `Point3D`

| Key | Type | Description |
| - | - | - |
| `x` | float (**required**) | The x coordinate of the point. |
| `y` | float (**required**) | The y coordinate of the point. |
| `z` | float (**required**) | The z coordinate of the point. |

## Definition: `CuboidGeometry`

| Key | Type | Description |
| - | - | - |
| `position` | [`Point3D`](#definition-point3d) (**required**) | The center of the cuboid. |
| `dimensions` | [`Point3D`](#definition-point3d) (**required**) | The length, width, and height of the cuboid. |
| `yaw` | float (**required**) | The rotation, in radians, about the z axis of the cuboid. |


## OpenAPI

````yaml openapi/nucleus.json POST /dataset/{dataset_id}/model/{model_id}/uploadPredictions
openapi: 3.1.0
info:
  title: Nucleus API
  version: '1.1'
servers:
  - url: https://api.scale.com/v1/nucleus
security:
  - sec0: []
paths:
  /dataset/{dataset_id}/model/{model_id}/uploadPredictions:
    post:
      summary: Upload Model Predictions
      operationId: upload-model-predictions
      parameters:
        - name: dataset_id
          in: path
          description: The Scale-generated ID of the Dataset.
          schema:
            type: string
          required: true
        - name: model_id
          in: path
          description: The Scale-generated ID of the Model.
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                annotations:
                  type: array
                  description: >-
                    Array of `GeometricPrediction` objects to upload. One or
                    both of `annotations` or `segmentations` must be supplied.
                  items:
                    properties:
                      reference_id:
                        type: string
                        description: >-
                          User-defined ID of the image to which to apply this
                          Prediction.
                      annotation_id:
                        type: string
                        description: >-
                          Optional unique ID that uniquely identifies this
                          Prediction within its target DatasetItem. Upon ingest,
                          a matching annotation ID will be ignored by default,
                          and updated if update=True for dataset.annotate. If
                          not supplied, an annotation_id will be generated
                          automatically. We do not support annotation_id for
                          category predictions.
                      label:
                        type: string
                        description: Label for this car (e.g. car, pedestrian, bicycle).
                      type:
                        type: string
                        description: One of `box`, `polygon`, `cuboid`, or `category`.
                      geometry:
                        type: object
                        description: >-
                          One of [BoxGeometry](#definition-boxgeometry),
                          [PolygonGeometry](#definition-polygongeometry),
                          [CuboidGeometry](#definition-cuboidgeometry) or an
                          empty geometry object {}. Must correspond with the
                          `type`. Set geometry to {} for category predictions
                          since category predictions have no notion of geometry.
                      confidence:
                        type: number
                        description: Optional confidence level within [0,1].
                        format: float
                      class_pdf:
                        type: object
                        description: >-
                          Optional class probability distribution. Maps each
                          class `label` to a probability value within [0,1] such
                          that all values sum to 1.
                      metadata:
                        type: string
                        description: Arbitrary metadata blob for the prediction.
                      taxonomy_name:
                        type: string
                        description: Optional name of the taxonomy for the prediction.
                    required:
                      - reference_id
                      - label
                      - type
                      - geometry
                    type: object
                segmentations:
                  type: array
                  description: >-
                    Array of `SegmentationPrediction` objects to upload. One or
                    both of `annotations` or `segmentations` must be supplied.
                  items:
                    properties:
                      reference_id:
                        type: string
                        description: >-
                          User-specified ID of the image to which to apply this
                          Annotation.
                      annotation_id:
                        type: string
                        description: >-
                          Optional unique ID that uniquely identifies this
                          Prediction within its target DatasetItem. Upon ingest,
                          a matching annotation ID will be ignored by default,
                          and updated if update=True for dataset.annotate. If
                          not supplied, an annotation_id will be generated
                          automatically.
                      mask_url:
                        type: string
                        description: >-
                          URL pointing to the segmentation prediction mask which
                          is accessible to Scale. The mask is an HxW int8 array
                          saved in PNG format, with each pixel value ranging
                          from [0, N), where N is the number of possible classes
                          (for semantic segmentation) or instances (for instance
                          segmentation). The height and width of the mask must
                          be the same as the original image. The class name for
                          each value in the mask is stored in the list of
                          Segment objects passed for `annotations`.
                      annotations:
                        type: array
                        description: >-
                          Array of `Segments`, which represent mappings between
                          the integer values contained in `mask_url` and class
                          labels.
                        items:
                          properties:
                            index:
                              type: integer
                              description: >-
                                Pixel value in the mask (i.e. [0,N) for N
                                classes/instances) to which this mapping refers.
                              format: int32
                            label:
                              type: string
                              description: >-
                                Name of the class for the class/instance
                                corresponding to `index` in the associated mask.
                            metadata:
                              type: string
                              description: Arbitrary metadata blob for the segment.
                          required:
                            - index
                            - label
                          type: object
                      type:
                        type: string
                        description: For segmentation, this `type` will always be `mask`.
                    required:
                      - reference_id
                      - mask_url
                      - type
                    type: object
                update:
                  type: boolean
                  description: >-
                    Whether to overwrite existing predictions upon
                    `reference_id` and `annotation_id` collision. For category
                    predictions, determines whether to overwrite upon
                    `taxonomy_name` and `reference_id` collision.
                  default: false
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value: {}
              schema:
                type: object
                properties: {}
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Result:
                  value: {}
              schema:
                type: object
                properties: {}
      deprecated: false
components:
  securitySchemes:
    sec0:
      type: http
      scheme: basic

````