> ## Documentation Index
> Fetch the complete documentation index at: https://docs.epigos.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Predictions

> Run inference on an image and retrieve predictions.

Epigos offers an API that allows you to make predictions from your model.
This API is accessible within the Epigos Python SDK.

<Note>
  You'll need to [Create an API Key](/workspace/api-keys) to
  [Authentication](/api-reference/introduction#authentication) with Epigos AI.
</Note>

# Image classification

You can predict the class or label of an image using the `predict()` function when you load a classification model.

## classification()

Loads classification model deployed on the platform.

| Param      | Type   | Description                                        |
| ---------- | ------ | -------------------------------------------------- |
| `model_id` | string | The unique ID of your model deployed on Epigos AI. |

```python theme={null}
import epigos

client = epigos.Epigos("api_key")

# load classification model
model = client.classification("model_id")
```

### predict()

Makes predictions for the classification model.

| Param        | Type   | Description                                                   |
| ------------ | ------ | ------------------------------------------------------------- |
| `image_path` | string | Path to image (can be local file or remote url).              |
| `confidence` | float  | Optional confidence threshold used to filter out predictions. |

#### Example using remote url

```python theme={null}
results = model.predict("https://foo.bar/image.jpg")
print(results.dict())
{
   "category" : "cat",
   "confidence" : 0.854,
   "predictions" : [
      {
         "category" : "cat",
         "confidence" : 0.854
      },
      {
         "category" : "dog",
         "confidence" : 0.146
      }
   ]
}
```

#### Example using image path

```python theme={null}
results = model.predict("path/to/your/image.jpg")
print(results.dict())
{
   "category" : "cat",
   "confidence" : 0.854,
   "predictions" : [
      {
         "category" : "cat",
         "confidence" : 0.854
      },
      {
         "category" : "dog",
         "confidence" : 0.146
      }
   ]
}
```

# Object detection

You can detect objects in an image using the `detect()` function when you load an object detection model.

## object\_detection()

Loads an object detection model deployed on the platform.

| Param      | Type   | Description                                        |
| ---------- | ------ | -------------------------------------------------- |
| `model_id` | string | The unique ID of your model deployed on Epigos AI. |

```python theme={null}
import epigos

client = epigos.Epigos("api_key")

# load object detection model
model = client.object_detection("model_id")
```

### detect()

Makes detection for the object detection model.

| Param          | Type    | Description                                                                          |
| -------------- | ------- | ------------------------------------------------------------------------------------ |
| `image_path`   | string  | Path to image (can be local file or remote url).                                     |
| `confidence`   | float   | Optional confidence threshold used to filter out predictions.                        |
| `annotate`     | boolean | Optional annotate flag to specify whether to annotate the image or not.              |
| `show_prob`    | boolean | Optional show\_prob to specify whether detection confidence are shown on the labels. |
| `stroke_width` | number  | Optional stroke width to specify bounding box border width.                          |

#### Example using remote url

```python theme={null}
results = model.detect("https://foo.bar/image.jpg")
print(results.dict())
{
   "detections": [
        {
            "label": "car",
            "confidence": 0.954,
            "x": 281,
            "y": 187,
            "width": 46,
            "height": 36
        }
    ],
    "image": "<base64 image>",
    "labelsCount": [
        {
            "label": "car",
            "total": 1
        }
    ]
}
```

#### Example using image path

```python theme={null}
results = model.detect("path/to/your/image.jpg")
print(results.dict())
{
   "detections": [
        {
            "label": "car",
            "confidence": 0.954,
            "x": 281,
            "y": 187,
            "width": 46,
            "height": 36
        }
    ],
    "image": "<base64 image>",
    "labelsCount": [
        {
            "label": "car",
            "total": 1
        }
    ]
}
```

#### Example using annotation options

```python theme={null}
from epigos.core.object_detection import DetectOptions

options = DetectOptions(annotate=True, stroke_width=3)
results = model.detect("path/to/your/image.jpg", options=options)

print(results.dict())
{
   "detections": [
        {
            "label": "car",
            "confidence": 0.954,
            "x": 281,
            "y": 187,
            "width": 46,
            "height": 36
        }
    ],
    "image": "<base64 image>",
    "labelsCount": [
        {
            "label": "car",
            "total": 1
        }
    ]
}
```

***

Checkout the code on [Github](https://github.com/Epigos-AI/epigos-python)
