Skip to content

Commit 851d536

Browse files
authored
Merge pull request #460 from superannotateai/friday
Friday
2 parents eda7d93 + 050cb2a commit 851d536

File tree

10 files changed

+802
-30
lines changed

10 files changed

+802
-30
lines changed

docs/source/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@
5454
html_static_path = []
5555

5656
autodoc_typehints = "description"
57+
html_show_sourcelink = False
58+
59+
html_context = {
60+
"display_github": False, # Add 'Edit on Github' link instead of 'View page source'
61+
"last_updated": True,
62+
"commit": False,
63+
}

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
superannotate_schemas>=v1.0.45dev1
1+
superannotate_schemas>=v1.0.45dev5
22

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ def upload_image_to_project(
20492049
def search_models(
20502050
self,
20512051
name: Optional[NotEmptyStr] = None,
2052-
type_: Optional[NotEmptyStr] = None,
2052+
type_: Optional[NotEmptyStr] = None, # noqa
20532053
project_id: Optional[int] = None,
20542054
task: Optional[NotEmptyStr] = None,
20552055
include_global: Optional[StrictBool] = True,
@@ -2058,17 +2058,21 @@ def search_models(
20582058
20592059
:param name: search string
20602060
:type name: str
2061-
:param type_: ml model type string
2062-
:type type_: str
2061+
2062+
:param type\_: ml model type string
2063+
:type type\_: str
2064+
20632065
:param project_id: project id
20642066
:type project_id: int
2067+
20652068
:param task: training task
20662069
:type task: str
2070+
20672071
:param include_global: include global ml models
20682072
:type include_global: bool
20692073
2070-
:return: ml model metadata
2071-
:rtype: list of dicts
2074+
:return: ml model metadata
2075+
:rtype: list of dicts
20722076
"""
20732077
res = self.controller.search_models(
20742078
name=name,
@@ -2227,7 +2231,7 @@ def validate_annotations(
22272231
with open(annotations_json) as file:
22282232
annotation_data = json.loads(file.read())
22292233
response = Controller.validate_annotations(
2230-
project_type, annotation_data, allow_extra=False
2234+
project_type, annotation_data
22312235
)
22322236
if response.errors:
22332237
raise AppException(response.errors)

src/superannotate/lib/core/usecases/items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def validate_arguments(self):
155155
raise AppException(
156156
"The query and subset params cannot have the value None at the same time."
157157
)
158-
if all([self._query, self._subset]) and not self._folder.is_root:
158+
if self._subset and not self._folder.is_root:
159159
raise AppException(
160160
"The folder name should be specified in the query string."
161161
)

src/superannotate/lib/core/video_convertor.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Annotation(BaseModel):
1818
classId: Optional[int]
1919
x: Optional[Any]
2020
y: Optional[Any]
21-
points: Optional[Dict]
21+
points: Any
2222
attributes: Optional[List[Any]] = []
2323
keyframe: bool = False
2424

@@ -30,10 +30,11 @@ class FrameAnnotation(BaseModel):
3030

3131
class VideoFrameGenerator:
3232
def __init__(self, annotation_data: dict, fps: int):
33-
self.validate_annotations(annotation_data)
3433
self.id_generator = iter(itertools.count(0))
3534
self._annotation_data = annotation_data
36-
self.duration = annotation_data["metadata"]["duration"] / (1000 * 1000)
35+
duration = annotation_data["metadata"]["duration"]
36+
duration = 0 if not duration else duration
37+
self.duration = duration / (1000 * 1000)
3738
self.fps = fps
3839
self.ratio = 1000 * 1000 / fps
3940
self._frame_id = 1
@@ -42,12 +43,6 @@ def __init__(self, annotation_data: dict, fps: int):
4243
self._mapping = {}
4344
self._process()
4445

45-
@staticmethod
46-
def validate_annotations(annotation_data: dict):
47-
duration = annotation_data["metadata"].get("duration")
48-
if duration is None:
49-
raise AppException("Video not annotated yet")
50-
5146
def get_frame(self, frame_no: int):
5247
try:
5348
return self.annotations[frame_no]
@@ -81,10 +76,9 @@ def _interpolate(
8176
"x": round(data["x"] + steps["x"] * idx, 2),
8277
"y": round(data["y"] + steps["y"] * idx, 2),
8378
}
84-
elif annotation_type in (AnnotationTypes.POLYGON, AnnotationTypes.POLYLINE):
85-
tmp_data["points"] = [
86-
point + steps[idx] * 2 for idx, point in enumerate(data["points"])
87-
]
79+
else:
80+
tmp_data["points"] = data["points"]
81+
8882
annotations[frame_idx] = Annotation(
8983
instanceId=instance_id,
9084
type=annotation_type,

src/superannotate/lib/infrastructure/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ def delete_annotations(
13551355

13561356
@staticmethod
13571357
def validate_annotations(
1358-
project_type: str, annotation: dict, allow_extra: bool = False
1358+
project_type: str, annotation: dict, allow_extra: bool = True
13591359
):
13601360
use_case = usecases.ValidateAnnotationUseCase(
13611361
project_type,

src/superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.3.5dev17"
1+
__version__ = "4.3.5dev23"

tests/integration/annotations/test_get_annotations_per_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def annotations_path(self):
3838
return os.path.join(self.folder_path, self.ANNOTATIONS_PATH)
3939

4040
def test_video_annotation_upload(self):
41-
# sa.create_annotation_classes_from_classes_json(self.PROJECT_NAME, self.classes_path)
41+
sa.create_annotation_classes_from_classes_json(self.PROJECT_NAME, self.classes_path)
4242

4343
_, _, _ = sa.attach_items(
4444
self.PROJECT_NAME,

tests/unit/test_validators.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import tempfile
44
from os.path import dirname
55
from unittest import TestCase
6-
`from unittest.mock import patch
7-
`
8-
from pydantic import ValidationError
6+
from unittest.mock import patch
97

10-
from src.superannotate import SAClient
11-
sa = SAClient()
128
from superannotate_schemas.validators import AnnotationValidators
139

10+
from src.superannotate import SAClient
1411

12+
sa = SAClient()
1513
VECTOR_ANNOTATION_JSON_WITH_BBOX = """
1614
{
1715
"metadata": {
@@ -1668,7 +1666,6 @@ def test_validate_video_point_labels(self, mock_print):
16681666
"instances[0].meta.pointLabels value is not a valid dict",
16691667
)
16701668

1671-
16721669
def test_validate_video_point_labels_bad_keys(self):
16731670
with tempfile.TemporaryDirectory() as tmpdir_name:
16741671
with open(f"{tmpdir_name}/test_validate_video_point_labels_bad_keys.json",

0 commit comments

Comments
 (0)