samgis_core 1.1.1__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- samgis_core/prediction_api/sam_onnx.py +6 -6
- samgis_core/utilities/serialize.py +2 -3
- samgis_core/utilities/type_hints.py +38 -13
- {samgis_core-1.1.1.dist-info → samgis_core-1.2.0.dist-info}/METADATA +5 -3
- {samgis_core-1.1.1.dist-info → samgis_core-1.2.0.dist-info}/RECORD +6 -6
- {samgis_core-1.1.1.dist-info → samgis_core-1.2.0.dist-info}/WHEEL +0 -0
@@ -32,7 +32,7 @@ from onnxruntime import get_available_providers, InferenceSession
|
|
32
32
|
|
33
33
|
from samgis_core import app_logger, MODEL_FOLDER
|
34
34
|
from samgis_core.utilities.constants import DEFAULT_INPUT_SHAPE, MODEL_ENCODER_NAME, MODEL_DECODER_NAME
|
35
|
-
from samgis_core.utilities.type_hints import PIL_Image,
|
35
|
+
from samgis_core.utilities.type_hints import PIL_Image, ListDict, TupleNdarrayInt, EmbeddingDict, EmbeddingImage
|
36
36
|
|
37
37
|
|
38
38
|
class SegmentAnythingONNX:
|
@@ -257,8 +257,8 @@ class SegmentAnythingONNX:
|
|
257
257
|
|
258
258
|
|
259
259
|
def get_raster_inference(
|
260
|
-
img: PIL_Image or ndarray, prompt:
|
261
|
-
) ->
|
260
|
+
img: PIL_Image or ndarray, prompt: ListDict, models_instance: SegmentAnythingONNX, model_name: str
|
261
|
+
) -> TupleNdarrayInt:
|
262
262
|
"""
|
263
263
|
Get inference output for a given image using a SegmentAnythingONNX model
|
264
264
|
|
@@ -318,7 +318,7 @@ def get_inference_embedding(
|
|
318
318
|
|
319
319
|
|
320
320
|
def get_raster_inference_using_existing_embedding(
|
321
|
-
embedding: dict, prompt:
|
321
|
+
embedding: dict, prompt: ListDict, models_instance: SegmentAnythingONNX) -> TupleNdarrayInt:
|
322
322
|
"""
|
323
323
|
Get inference output for a given image using a SegmentAnythingONNX model, using an existing embedding instead of a
|
324
324
|
new ndarray or PIL image
|
@@ -345,8 +345,8 @@ def get_raster_inference_using_existing_embedding(
|
|
345
345
|
|
346
346
|
|
347
347
|
def get_raster_inference_with_embedding_from_dict(
|
348
|
-
img: PIL_Image or ndarray, prompt:
|
349
|
-
embedding_key: str, embedding_dict: dict) ->
|
348
|
+
img: PIL_Image or ndarray, prompt: ListDict, models_instance: SegmentAnythingONNX, model_name: str,
|
349
|
+
embedding_key: str, embedding_dict: dict) -> TupleNdarrayInt:
|
350
350
|
"""
|
351
351
|
Get inference output using a SegmentAnythingONNX model, but get the image embedding from the given embedding dict
|
352
352
|
instead of creating a new embedding. This function needs the img argument to update the embedding dict if necessary
|
@@ -2,7 +2,6 @@
|
|
2
2
|
from typing import Mapping
|
3
3
|
|
4
4
|
from samgis_core import app_logger
|
5
|
-
from samgis_core.utilities.type_hints import dict_str, dict_str_any
|
6
5
|
|
7
6
|
|
8
7
|
def serialize(obj: any, include_none: bool = False):
|
@@ -74,11 +73,11 @@ def _serialize_list(ls: list, include_none: bool) -> list:
|
|
74
73
|
return [_serialize(elem, include_none) for elem in ls]
|
75
74
|
|
76
75
|
|
77
|
-
def _serialize_bytes(b: bytes) ->
|
76
|
+
def _serialize_bytes(b: bytes) -> dict[str, str]:
|
78
77
|
import base64
|
79
78
|
encoded = base64.b64encode(b)
|
80
79
|
return {"value": encoded.decode('ascii'), "type": "bytes"}
|
81
80
|
|
82
81
|
|
83
|
-
def _serialize_exception(e: Exception) ->
|
82
|
+
def _serialize_exception(e: Exception) -> dict[str, str]:
|
84
83
|
return {"msg": str(e), "type": str(type(e)), **e.__dict__}
|
@@ -1,22 +1,47 @@
|
|
1
1
|
"""custom type hints"""
|
2
2
|
from enum import Enum
|
3
|
-
from typing import TypedDict
|
3
|
+
from typing import TypedDict, NewType
|
4
4
|
|
5
5
|
from PIL.Image import Image
|
6
6
|
from numpy import ndarray
|
7
7
|
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
class DictStrInt(dict[str, int]): pass
|
10
|
+
|
11
|
+
|
12
|
+
class DictStr(dict[str]): pass
|
13
|
+
|
14
|
+
|
15
|
+
class DictStrAny(dict[str, any]): pass
|
16
|
+
|
17
|
+
|
18
|
+
class ListDict(list[dict]): pass
|
19
|
+
|
20
|
+
|
21
|
+
class ListFloat(list[float]): pass
|
22
|
+
|
23
|
+
|
24
|
+
class ListInt(list[int]): pass
|
25
|
+
|
26
|
+
|
27
|
+
class TupleInt(tuple[int]): pass
|
28
|
+
|
29
|
+
|
30
|
+
class TupleNdarrayInt(tuple[ndarray, int]): pass
|
31
|
+
|
32
|
+
|
33
|
+
class TupleNdarrayFloat(tuple[ndarray, float]): pass
|
34
|
+
|
35
|
+
|
36
|
+
class LlistFloat(ListFloat): pass
|
37
|
+
|
38
|
+
|
39
|
+
class TupleFloat(tuple[float]): pass
|
40
|
+
|
41
|
+
|
42
|
+
class TupleFloatAny(tuple[float, any]): pass
|
43
|
+
|
44
|
+
|
20
45
|
PIL_Image = Image
|
21
46
|
|
22
47
|
|
@@ -26,7 +51,7 @@ class StrEnum(str, Enum):
|
|
26
51
|
|
27
52
|
class EmbeddingImage(TypedDict):
|
28
53
|
image_embedding: ndarray
|
29
|
-
original_size:
|
54
|
+
original_size: TupleInt
|
30
55
|
transform_matrix: ndarray
|
31
56
|
|
32
57
|
|
@@ -1,17 +1,19 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: samgis_core
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.2.0
|
4
4
|
Summary: SamGIS CORE
|
5
5
|
License: MIT
|
6
6
|
Author: alessandro trinca tornidor
|
7
7
|
Author-email: alessandro@trinca.tornidor.com
|
8
|
-
Requires-Python: >=3.10,<3.
|
8
|
+
Requires-Python: >=3.10,<3.12
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
12
13
|
Requires-Dist: bson (>=0.5.10,<0.6.0)
|
13
14
|
Requires-Dist: loguru (>=0.7.2,<0.8.0)
|
14
|
-
Requires-Dist: numpy (==1.25.2)
|
15
|
+
Requires-Dist: numpy (==1.25.2) ; python_version >= "3.10" and python_version < "3.11"
|
16
|
+
Requires-Dist: numpy (>=1.26,<2.0) ; python_version >= "3.11" and python_version < "3.12"
|
15
17
|
Requires-Dist: onnxruntime (==1.16.3)
|
16
18
|
Requires-Dist: opencv-python-headless (==4.8.1.78)
|
17
19
|
Requires-Dist: pillow (>=10.2.0,<11.0.0)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
samgis_core/__init__.py,sha256=1kFX8G22dxNz23J7uOYl-SMWOe4W1olssc-5zKAVwSc,351
|
2
2
|
samgis_core/__version__.py,sha256=x-8LeQkljky-ao1MyT98tSQE1xNvJp3LelqsAdCb9Og,94
|
3
3
|
samgis_core/prediction_api/__init__.py,sha256=_jUZhspS26ygiSzBJywfZ4fQf9X7oC8w6oxvhd9S2hQ,57
|
4
|
-
samgis_core/prediction_api/sam_onnx.py,sha256=
|
4
|
+
samgis_core/prediction_api/sam_onnx.py,sha256=YEX6UOFKcqPiuF_SCPAcK_gCmxoj4lvTLNNDul2htZ8,15320
|
5
5
|
samgis_core/utilities/__init__.py,sha256=nL9pzdB4SdEF8m5gCbtlVCtdGLg9JjPm-FNxKBsIBZA,32
|
6
6
|
samgis_core/utilities/constants.py,sha256=645W57jrUNbnujgUwCietfr-rECENDXLGmHeD2YoSwg,157
|
7
7
|
samgis_core/utilities/fastapi_logger.py,sha256=yt8Vj1viyE-Kry1_iy5p4saZvGEEmRfuTEMHYXgnjqk,650
|
8
|
-
samgis_core/utilities/serialize.py,sha256=
|
9
|
-
samgis_core/utilities/type_hints.py,sha256=
|
8
|
+
samgis_core/utilities/serialize.py,sha256=aIjhEoibBpV_gpgOg6LiVxZCWjOkYxlzcboDZLQctJE,2689
|
9
|
+
samgis_core/utilities/type_hints.py,sha256=iDkWiVB2B0W_GaRhdpypEra2FvQtwC5lNLVZr7a4yhU,845
|
10
10
|
samgis_core/utilities/utilities.py,sha256=fP3cnxIYULYoCBft54EAivUR_fMcCDz2Z9AMpAO0zZ0,2434
|
11
|
-
samgis_core-1.
|
12
|
-
samgis_core-1.
|
13
|
-
samgis_core-1.
|
11
|
+
samgis_core-1.2.0.dist-info/METADATA,sha256=KyKxRzuNtyUNY5twG1UmLayLh6PHxhwHzbzakJBL6JM,1088
|
12
|
+
samgis_core-1.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
13
|
+
samgis_core-1.2.0.dist-info/RECORD,,
|
File without changes
|