Skip to content

Commit f224377

Browse files
authored
Merge pull request #1939 from kili-technology/feature/lab-3861-support-multipoint-multilinestring-geometrycollection
feat(LAB-3861): support GeoJSON `MultiPoint` & `MultiLineString`
2 parents 537a6fc + fc11b37 commit f224377

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies = [
4444
"filelock >= 3.0.0, < 4.0.0",
4545
"pip-system-certs >= 4.0.0, < 5.0.0; platform_system=='Windows'",
4646
"pyrate-limiter >= 3, < 4",
47-
"kili-formats == 0.2.8"
47+
"kili-formats == 0.2.9"
4848
]
4949
urls = { homepage = "https://github.com/kili-technology/kili-python-sdk" }
5050

@@ -84,7 +84,7 @@ dev = [
8484
"vulture==2.11",
8585
"dead==1.5.2",
8686
# optional dependencies
87-
"kili-formats[all] == 0.2.8",
87+
"kili-formats[all] == 0.2.9",
8888
"opencv-python >= 4.0.0, < 5.0.0",
8989
"azure-storage-blob >= 12.0.0, < 13.0.0",
9090
# optional dependencies gis
@@ -101,7 +101,7 @@ dev = [
101101
all = [
102102
# aggregate all optional deps without dev
103103
"azure-storage-blob >= 12.0.0, < 13.0.0",
104-
"kili-formats[all] == 0.2.8",
104+
"kili-formats[all] == 0.2.9",
105105
"opencv-python >= 4.0.0, < 5.0.0",
106106
"Pillow >=9.0.0, <11.0.0",
107107
"pyproj == 3.6.1; python_version >= '3.9'",
@@ -115,7 +115,7 @@ cli = [
115115
"tabulate >= 0.9.0, < 0.10.0"
116116
]
117117
coco = [
118-
"kili-formats[coco] == 0.2.8"
118+
"kili-formats[coco] == 0.2.9"
119119
]
120120
gis = [
121121
"pyproj >= 2.6.1, < 3; python_version < '3.9'",
@@ -124,12 +124,12 @@ gis = [
124124
]
125125
image = [
126126
"Pillow >=9.0.0, <11.0.0",
127-
"kili-formats[image] == 0.2.8"
127+
"kili-formats[image] == 0.2.9"
128128
]
129129
image-utils = ["opencv-python >= 4.0.0, < 5.0.0"]
130130

131131
video = [
132-
"kili-formats[video] == 0.2.8"
132+
"kili-formats[video] == 0.2.9"
133133
]
134134
yolo = [
135135
"pyyaml >= 6.0, < 7.0"

src/kili/presentation/client/label.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,9 @@ def append_labels_from_shapefiles(
13651365
job_names: List[str],
13661366
category_names: List[str],
13671367
from_epsgs: Optional[List[int]] = None,
1368+
label_type: LabelType = "DEFAULT",
1369+
step_name: Optional[str] = None,
1370+
model_name: Optional[str] = None,
13681371
):
13691372
"""Import and convert shapefiles into annotations for a specific asset in a Kili project.
13701373
@@ -1383,6 +1386,11 @@ def append_labels_from_shapefiles(
13831386
from_epsgs: Optional list of EPSG codes specifying the coordinate reference systems
13841387
of the shapefiles. If not provided, EPSG:4326 (WGS84) is assumed for all files.
13851388
All geometries will be transformed to EPSG:4326 before being added to Kili.
1389+
label_type: Can be one of `AUTOSAVE`, `DEFAULT`, `PREDICTION`, `REVIEW` or `INFERENCE`.
1390+
step_name: Name of the step to which the labels belong.
1391+
The label_type must match accordingly.
1392+
model_name: Name of the model that generated the labels.
1393+
Only useful when uploading PREDICTION or INFERENCE labels.
13861394
13871395
Note:
13881396
This function requires the 'gis' extra dependencies.
@@ -1404,6 +1412,9 @@ def append_labels_from_shapefiles(
14041412
project_id=project_id,
14051413
json_response_array=[json_response],
14061414
asset_external_id_array=[asset_external_id],
1415+
label_type=label_type,
1416+
step_name=step_name,
1417+
model_name=model_name,
14071418
)
14081419

14091420
# pylint: disable=too-many-branches
@@ -1415,6 +1426,9 @@ def append_labels_from_geojson_files(
14151426
geojson_file_paths: List[str],
14161427
job_names: Optional[List[str]] = None,
14171428
category_names: Optional[List[str]] = None,
1429+
label_type: LabelType = "DEFAULT",
1430+
step_name: Optional[str] = None,
1431+
model_name: Optional[str] = None,
14181432
):
14191433
"""Import and convert GeoJSON files into annotations for a specific asset in a Kili project.
14201434
@@ -1444,6 +1458,12 @@ def append_labels_from_geojson_files(
14441458
When provided, all geometries from the corresponding file will be assigned
14451459
to this category. Must have the same length as `geojson_file_paths`.
14461460
Each category must exist in the corresponding job's ontology.
1461+
label_type: Can be one of `AUTOSAVE`, `DEFAULT`, `PREDICTION`, `REVIEW` or `INFERENCE`.
1462+
step_name: Name of the step to which the labels belong.
1463+
The label_type must match accordingly.
1464+
model_name: Name of the model that generated the labels.
1465+
Only useful when uploading PREDICTION or INFERENCE labels.
1466+
14471467
14481468
Note:
14491469
**Geometry-to-job compatibility:**
@@ -1549,4 +1569,7 @@ def append_labels_from_geojson_files(
15491569
project_id=project_id,
15501570
json_response_array=[merged_json_response],
15511571
asset_external_id_array=[asset_external_id],
1572+
label_type=label_type,
1573+
step_name=step_name,
1574+
model_name=model_name,
15521575
)

src/kili/utils/labels/geojson.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def create_kili_property(job_name, job_config, annotation_type):
7171
geometry_type = feature.get("geometry", {}).get("type")
7272
kili_property = None
7373

74-
if geometry_type == "Point" and marker_job:
74+
if geometry_type in ["Point", "MultiPoint"] and marker_job:
7575
job_name, job_config = marker_job
7676
kili_property = create_kili_property(job_name, job_config, "marker")
7777

78-
elif geometry_type == "LineString" and polyline_job:
78+
elif geometry_type in ["LineString", "MultiLineString"] and polyline_job:
7979
job_name, job_config = polyline_job
8080
kili_property = create_kili_property(job_name, job_config, "polyline")
8181

@@ -156,9 +156,9 @@ def create_kili_property(annotation_type: str):
156156
kili_property = None
157157

158158
# Map geometry types to annotation types based on available tools
159-
if geometry_type == "Point" and "marker" in tools:
159+
if geometry_type in ["Point", "MultiPoint"] and "marker" in tools:
160160
kili_property = create_kili_property("marker")
161-
elif geometry_type == "LineString" and "polyline" in tools:
161+
elif geometry_type in ["LineString", "MultiLineString"] and "polyline" in tools:
162162
kili_property = create_kili_property("polyline")
163163
elif geometry_type == "Polygon":
164164
if "polygon" in tools:

0 commit comments

Comments
 (0)