Using the Python SDK
If you're integrating with our APIs using Python, the Dragoneye SDK streamlines the process with minimal setup. Here's how you can get started and explore the types and endpoints in detail.
Installation
Install the package using pip.
pip install dragoneye-python
Quick Start
To call the classifier, follow these steps:
from dragoneye import Dragoneye, Image
dragoneye_client = Dragoneye(api_key=<YOUR_ACCESS_TOKEN>)
prediction_result = dragoneye_client.classification.predict(
image=Image(file_or_bytes=image_file.file.read()),
model_name="dragoneye/fashion", # Change to your desired model name
)
Types and Endpoints
Types
TaxonType
(Enum)
Represents the type of taxon in the prediction.
CATEGORY
: Represents a category taxon.TRAIT
: Represents a trait taxon.
TaxonPrediction
Represents a predicted taxon (category or trait) returned by the API.
Attributes:
id
: Unique identifier for the taxon (TaxonID
).type
: The type of the taxon (TaxonType
).name
: The internal name of the taxon.displayName
: The user-friendly name of the taxon.score
: Optional confidence score for the prediction.children
: A sequence of nested childTaxonPrediction
objects.
ClassificationObjectPrediction
Represents the prediction of an object in an image.
Attributes:
normalizedBbox
: A bounding box for the detected object (coordinates are normalized).category
: The predicted category for the object (TaxonPrediction
).traits
: A sequence of trait predictions (ClassificationTraitRootPrediction
).
ClassificationPredictImageResponse
The response object returned after predicting an image.
Attributes:
predictions
: A sequence ofClassificationObjectPrediction
results.
TaxonID
A type alias for taxon IDs, represented as an int
.
NormalizedBbox
A type alias for normalized bounding boxes, represented as a tuple of four float values.
Endpoints
predict
(Image Classification)
Performs a classification prediction on a single image. You can pass either the image file or the URL of the image, and the SDK will return predictions based on the model specified.
Arguments:
image
: The image to be classified (can bebytes
or aBinaryIO
object).model_name
: The name of the model to be used for the prediction.
Response:
Returns a ClassificationPredictImageResponse
object containing prediction results.
predict_product
(Product Classification)
This method predicts categories and traits for a sequence of images of the same product.
Arguments:
images
: A sequence of images (either asbytes
orBinaryIO
).model_name
: The name of the model to be used for prediction.
Response:
Returns a ClassificationPredictProductResponse
object containing product prediction results.