samgis_core 1.1.1__tar.gz → 1.2.0__tar.gz

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.
@@ -1,17 +1,19 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: samgis_core
3
- Version: 1.1.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.11
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,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "samgis_core"
3
- version = "1.1.1"
3
+ version = "1.2.0"
4
4
  description = "SamGIS CORE"
5
5
  authors = ["alessandro trinca tornidor <alessandro@trinca.tornidor.com>"]
6
6
  license = "MIT license"
@@ -8,12 +8,18 @@ readme = "README.md"
8
8
 
9
9
  [metadata]
10
10
  name = "samgis_core"
11
- version = "1.1.1"
11
+ version = "1.2.0"
12
+
13
+ [project.urls]
14
+ Source = "https://gitlab.com/aletrn/samgis_core"
12
15
 
13
16
  [tool.poetry.dependencies]
14
- numpy = "1.25.2"
17
+ numpy = [
18
+ {version = "1.25.2", python = "~3.10"},
19
+ {version = "^1.26", python = "~3.11"}
20
+ ]
15
21
  pillow = "^10.2.0"
16
- python = "~3.10"
22
+ python = ">=3.10, <3.12"
17
23
  onnxruntime = "1.16.3"
18
24
  opencv-python-headless = "4.8.1.78"
19
25
  loguru = "^0.7.2"
@@ -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, list_dict, tuple_ndarr_int, EmbeddingDict, EmbeddingImage
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: list_dict, models_instance: SegmentAnythingONNX, model_name: str
261
- ) -> tuple_ndarr_int:
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: list_dict, models_instance: SegmentAnythingONNX) -> tuple_ndarr_int:
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: list_dict, models_instance: SegmentAnythingONNX, model_name: str,
349
- embedding_key: str, embedding_dict: dict) -> tuple_ndarr_int:
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) -> dict_str:
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) -> dict_str_any:
82
+ def _serialize_exception(e: Exception) -> dict[str, str]:
84
83
  return {"msg": str(e), "type": str(type(e)), **e.__dict__}
@@ -0,0 +1,58 @@
1
+ """custom type hints"""
2
+ from enum import Enum
3
+ from typing import TypedDict, NewType
4
+
5
+ from PIL.Image import Image
6
+ from numpy import ndarray
7
+
8
+
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
+
45
+ PIL_Image = Image
46
+
47
+
48
+ class StrEnum(str, Enum):
49
+ pass
50
+
51
+
52
+ class EmbeddingImage(TypedDict):
53
+ image_embedding: ndarray
54
+ original_size: TupleInt
55
+ transform_matrix: ndarray
56
+
57
+
58
+ EmbeddingDict = dict[str, EmbeddingImage]
@@ -1,33 +0,0 @@
1
- """custom type hints"""
2
- from enum import Enum
3
- from typing import TypedDict
4
-
5
- from PIL.Image import Image
6
- from numpy import ndarray
7
-
8
-
9
- dict_str_int = dict[str, int]
10
- dict_str = dict[str]
11
- dict_str_any = dict[str, any]
12
- list_dict = list[dict]
13
- list_float = list[float]
14
- list_int = list[int]
15
- tuple_int = tuple[int]
16
- tuple_ndarr_int = tuple[ndarray, int]
17
- llist_float = list[list_float]
18
- tuple_float = tuple[float]
19
- tuple_float_any = tuple[float, any]
20
- PIL_Image = Image
21
-
22
-
23
- class StrEnum(str, Enum):
24
- pass
25
-
26
-
27
- class EmbeddingImage(TypedDict):
28
- image_embedding: ndarray
29
- original_size: tuple_int
30
- transform_matrix: ndarray
31
-
32
-
33
- EmbeddingDict = dict[str, EmbeddingImage]
File without changes