Skip to content

Commit 73c9700

Browse files
committed
Fixing problem in regions annotations given as a list
1 parent 06859b4 commit 73c9700

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

HISTORY.rst

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
History
44
-------
55

6+
9.8.3 (2025-03-27)
7+
------------------
8+
9+
- Fixing annotations update for regions as lists.
10+
611
9.8.2 (2025-03-21)
712
------------------
813

bigml/api_handlers/sourcehandler.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,14 @@
6161
HTTP_CREATED, HTTP_BAD_REQUEST,
6262
HTTP_UNAUTHORIZED, HTTP_PAYMENT_REQUIRED, HTTP_NOT_FOUND,
6363
HTTP_TOO_MANY_REQUESTS,
64-
HTTP_INTERNAL_SERVER_ERROR, GAE_ENABLED, SEND_JSON)
64+
HTTP_INTERNAL_SERVER_ERROR, GAE_ENABLED, SEND_JSON, LOGGER)
6565
from bigml.bigmlconnection import json_load
6666
from bigml.api_handlers.resourcehandler import check_resource_type, \
6767
resource_is_ready, get_source_id, get_id
6868
from bigml.constants import SOURCE_PATH, IMAGE_EXTENSIONS
69-
from bigml.api_handlers.resourcehandler import ResourceHandlerMixin, LOGGER
69+
from bigml.api_handlers.resourcehandler import ResourceHandlerMixin
7070
from bigml.fields import Fields
7171

72-
LOG_FORMAT = '%(asctime)-15s: %(message)s'
73-
LOGGER = logging.getLogger('BigML')
74-
CONSOLE = logging.StreamHandler()
75-
CONSOLE.setLevel(logging.WARNING)
76-
LOGGER.addHandler(CONSOLE)
7772

7873
MAX_CHANGES = 5
7974
MAX_RETRIES = 5
@@ -548,7 +543,7 @@ def update_composite_annotations(self, source, images_file,
548543
"components": source_ids})
549544
elif optype == "regions":
550545
for value, source_id in values:
551-
if isinstance(value, dict):
546+
if isinstance(value, list):
552547
# dictionary should contain the bigml-coco format
553548
value = compact_regions(value)
554549
changes.append(

bigml/bigmlconnection.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
LOG_FORMAT = '%(asctime)-15s: %(message)s'
5252
LOGGER = logging.getLogger('BigML')
53-
CONSOLE = logging.StreamHandler()
53+
CONSOLE = logging.StreamHandler(sys.stdout)
5454
CONSOLE.setLevel(logging.WARNING)
5555
LOGGER.addHandler(CONSOLE)
5656

@@ -138,7 +138,7 @@ def debug_request(method, url, **kwargs):
138138
139139
"""
140140
response = original_request(method, url, **kwargs)
141-
logging.debug("Data: %s", response.request.body)
141+
LOGGER.debug("Data: %s", response.request.body)
142142
try:
143143
response_content = "Download status is %s" % response.status_code \
144144
if "download" in url else \
@@ -147,7 +147,7 @@ def debug_request(method, url, **kwargs):
147147
response_content = response.content
148148
response_content = response_content[0: 256] if short_debug else \
149149
response_content
150-
logging.debug("Response: %s\n", response_content)
150+
LOGGER.debug("Response: %s\n", response_content)
151151
return response
152152

153153
original_request = requests.api.request
@@ -213,9 +213,8 @@ def __init__(self, username=None, api_key=None,
213213
# when using GAE will fail
214214
pass
215215

216-
logging.basicConfig(format=LOG_FORMAT,
217-
level=logging_level,
218-
stream=sys.stdout)
216+
LOGGER.forma = LOG_FORMAT,
217+
LOGGER.level = logging_level
219218

220219
if username is None:
221220
try:

bigml/tests/test_22_source_args.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_scenario3(self):
126126
source_create.the_source_is_finished(
127127
self, example["source_wait"])
128128
source_create.the_cloned_source_origin_is(self, source)
129-
129+
130130
def test_scenario4(self):
131131
"""
132132
Scenario: Successfully adding annotatations to composite source:
@@ -142,6 +142,8 @@ def test_scenario4(self):
142142
['data/images/metadata.json', '500', '500', '12',
143143
'100002'],
144144
['data/images/metadata_compact.json', '500', '500', '3',
145+
'100003'],
146+
['data/images/metadata_list.json', '500', '500', '3',
145147
'100003']]
146148
show_doc(self.test_scenario4)
147149
for example in examples:
@@ -157,7 +159,7 @@ def test_scenario4(self):
157159
dataset_create.i_create_a_dataset(self)
158160
dataset_create.the_dataset_is_finished_in_less_than(
159161
self, example["dataset_wait"])
160-
dataset_create.check_annotations(self,
162+
dataset_create.check_annotations(self,
161163
example["annotations_field"],
162164
example["annotations_num"])
163165

bigml/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '9.8.2'
1+
__version__ = '9.8.3'

data/images/annotations_list.json

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[{"file": "f1/fruits1f.png", "my_regions": [{"label": "region1", "xmin": 0.2, "ymin": 0.2, "xmax": 0.4, "ymax": 0.4}]},
2+
{"file": "f1/fruits1.png", "my_regions": [{"label": "region2", "xmin": 0.2, "ymin": 0.2, "xmax": 0.4, "ymax": 0.4}, {"label": "region1", "xmin": 0.5, "ymin": 0.5, "xmax": 0.7, "ymax": 0.7}]}]

data/images/metadata_list.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{"description": "Fruit images to test colour distributions with regions",
2+
"images_file": "./fruits_hist.zip",
3+
"new_fields": [{"name": "my_regions", "optype": "regions"}],
4+
"source_id": null,
5+
"annotations": "./annotations_list.json"}

0 commit comments

Comments
 (0)