Skip to content

Dump bbox as string to avoid serialization issues #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deepomatic/api/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import sys
import copy
import base64
import json

from deepomatic.api.exceptions import DeepomaticException

Expand Down Expand Up @@ -102,6 +103,9 @@ def get_input(self):
}
if self.bbox is not None:
image['bbox'] = self.bbox
if self.need_multipart and isinstance(image['bbox'], dict):
# Convert the bbox to a string to allow serialization
image['bbox'] = json.dumps(image['bbox'])
if self.polygon is not None:
image['polygon'] = self.polygon
return {
Expand Down
10 changes: 10 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from deepomatic.api.http_retry import HTTPRetry
from deepomatic.api.inputs import ImageInput
from deepomatic.api.version import __title__, __version__
from io import BytesIO
from requests.exceptions import ConnectionError, MissingSchema
from tenacity import RetryError, stop_after_delay

Expand Down Expand Up @@ -259,6 +260,15 @@ def test_create_custom_reco_and_infer(self, client, custom_network):
max_predictions=3)
assert inference_schema(3, 0, 'golden retriever', 0.5) == result

# Test a binary image via multipart
response = requests.get(DEMO_URL)
img_data = BytesIO(response.content)
result = version.inference(inputs=[ImageInput(img_data, encoding='binary',
bbox={"xmin": 0.2, "ymin": 0.2, "xmax": 0.8, "ymax": 0.8})],
show_discarded=True,
max_predictions=3)
assert inference_schema(3, 0, 'golden retriever', 0.5) == result

versions = spec.versions()
assert versions.count() > 0
data = versions.data()
Expand Down