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

You’ll need to Create an API Key to Authentication with Epigos AI.

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.

ParamTypeDescription
model_idstringThe unique ID of your model deployed on Epigos AI.
import epigos

client = epigos.Epigos("api_key")

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

predict()

Makes predictions for the classification model.

ParamTypeDescription
image_pathstringPath to image (can be local file or remote url).
confidencefloatOptional confidence threshold used to filter out predictions.

Example using remote url

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

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.

ParamTypeDescription
model_idstringThe unique ID of your model deployed on Epigos AI.
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.

ParamTypeDescription
image_pathstringPath to image (can be local file or remote url).
confidencefloatOptional confidence threshold used to filter out predictions.
annotatebooleanOptional annotate flag to specify whether to annotate the image or not.
show_probbooleanOptional show_prob to specify whether detection confidence are shown on the labels.
stroke_widthnumberOptional stroke width to specify bounding box border width.

Example using remote url

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

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

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