rvimage 0.0.1__py3-none-any.whl → 0.1.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.
- rvimage/collection_types.py +32 -16
- rvimage-0.1.0.dist-info/METADATA +16 -0
- rvimage-0.1.0.dist-info/RECORD +7 -0
- rvimage-0.0.1.dist-info/METADATA +0 -9
- rvimage-0.0.1.dist-info/RECORD +0 -7
- {rvimage-0.0.1.dist-info → rvimage-0.1.0.dist-info}/WHEEL +0 -0
- {rvimage-0.0.1.dist-info → rvimage-0.1.0.dist-info}/top_level.txt +0 -0
rvimage/collection_types.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
from typing import Self
|
2
|
-
from pydantic import BaseModel
|
2
|
+
from pydantic import BaseModel, model_serializer, model_validator
|
3
3
|
import numpy as np
|
4
4
|
from rvimage.converters import (
|
5
5
|
extract_polys_from_mask,
|
@@ -11,11 +11,6 @@ from rvimage.converters import (
|
|
11
11
|
from rvimage.domain import BbF, BbI, Poly, enclosing_bb, find_ccs
|
12
12
|
|
13
13
|
|
14
|
-
class GeoFig(BaseModel):
|
15
|
-
bbox: BbF | None = None
|
16
|
-
poly: Poly | None = None
|
17
|
-
|
18
|
-
|
19
14
|
class Labelinfo(BaseModel):
|
20
15
|
new_label: str
|
21
16
|
labels: list[str]
|
@@ -26,10 +21,31 @@ class Labelinfo(BaseModel):
|
|
26
21
|
|
27
22
|
|
28
23
|
class BboxAnnos(BaseModel):
|
29
|
-
elts: list[
|
24
|
+
elts: list[BbF | Poly]
|
30
25
|
cat_idxs: list[int]
|
31
26
|
selected_mask: list[bool]
|
32
27
|
|
28
|
+
@model_validator(mode="before")
|
29
|
+
@classmethod
|
30
|
+
def resolve_bb_poly(cls, data: dict) -> dict:
|
31
|
+
# remove the type-info from the dict
|
32
|
+
data["elts"] = [next(v for v in d.values()) for d in data["elts"]]
|
33
|
+
return data
|
34
|
+
|
35
|
+
@model_serializer()
|
36
|
+
def serialize_model(self):
|
37
|
+
elts = [
|
38
|
+
{"BB": elt.model_dump()}
|
39
|
+
if isinstance(elt, BbF)
|
40
|
+
else {"Poly": elt.model_dump()}
|
41
|
+
for elt in self.elts
|
42
|
+
]
|
43
|
+
return {
|
44
|
+
"cat_idxs": self.cat_idxs,
|
45
|
+
"selected_mask": self.selected_mask,
|
46
|
+
"elts": elts,
|
47
|
+
}
|
48
|
+
|
33
49
|
@classmethod
|
34
50
|
def from_mask(cls, mask: np.ndarray, cat_idx: int) -> "BboxAnnos":
|
35
51
|
"""
|
@@ -40,7 +56,7 @@ class BboxAnnos(BaseModel):
|
|
40
56
|
|
41
57
|
return cls(
|
42
58
|
elts=[
|
43
|
-
|
59
|
+
Poly(points=points, enclosing_bb=enclosing_bb(points))
|
44
60
|
for points in polys
|
45
61
|
],
|
46
62
|
cat_idxs=cat_idxs,
|
@@ -60,9 +76,9 @@ class BboxAnnos(BaseModel):
|
|
60
76
|
def fill_mask(self, im_mask: np.ndarray, cat_idx: int):
|
61
77
|
fill_polys_on_mask(
|
62
78
|
polygons=(
|
63
|
-
elt.
|
79
|
+
elt.points
|
64
80
|
for elt, cat_idx_ in zip(self.elts, self.cat_idxs)
|
65
|
-
if cat_idx == cat_idx_ and elt
|
81
|
+
if cat_idx == cat_idx_ and isinstance(elt, Poly)
|
66
82
|
),
|
67
83
|
value=1,
|
68
84
|
im_mask=im_mask,
|
@@ -70,9 +86,9 @@ class BboxAnnos(BaseModel):
|
|
70
86
|
)
|
71
87
|
fill_bbs_on_mask(
|
72
88
|
bbs=(
|
73
|
-
elt
|
89
|
+
elt
|
74
90
|
for elt, cat_idx_ in zip(self.elts, self.cat_idxs)
|
75
|
-
if cat_idx == cat_idx_ and elt
|
91
|
+
if cat_idx == cat_idx_ and isinstance(elt, BbF)
|
76
92
|
),
|
77
93
|
value=1,
|
78
94
|
im_mask=im_mask,
|
@@ -125,10 +141,10 @@ class BrushData(BaseModel):
|
|
125
141
|
|
126
142
|
|
127
143
|
class InputAnnotationData(BaseModel):
|
128
|
-
bbox: BboxData
|
129
|
-
brush: BrushData
|
144
|
+
bbox: BboxData | None
|
145
|
+
brush: BrushData | None
|
130
146
|
|
131
147
|
|
132
148
|
class OutputAnnotationData(BaseModel):
|
133
|
-
bbox: BboxAnnos
|
134
|
-
brush: BrushAnnos
|
149
|
+
bbox: BboxAnnos | None
|
150
|
+
brush: BrushAnnos | None
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: rvimage
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Pydantic types to facilitate writing prediction APIs integrated into the image annotation tool RV Image
|
5
|
+
Project-URL: Repository, https://github.com/bertiqwerty/rvimage
|
6
|
+
Requires-Python: >=3.12
|
7
|
+
Description-Content-Type: text/markdown
|
8
|
+
Requires-Dist: numpy>=2.3.0
|
9
|
+
Requires-Dist: opencv-python-headless>=4.11.0.86
|
10
|
+
Requires-Dist: pydantic>=2.11.7
|
11
|
+
Requires-Dist: scipy>=1.15.3
|
12
|
+
|
13
|
+
# RV Image
|
14
|
+
|
15
|
+
This package contains Pydantic types to facilitate writing prediction APIs integrated into the image annotation tool
|
16
|
+
[RV Image](https://github.com/bertiqwerty/rvimage).
|
@@ -0,0 +1,7 @@
|
|
1
|
+
rvimage/collection_types.py,sha256=NvAjVrGl9HZKYSYGm71Y74opjW1llKHcS90T5x3H04Y,4071
|
2
|
+
rvimage/converters.py,sha256=gBHgknXMuAVQnB6birZKXdFMFnbouv88QKba3JAiSPA,2578
|
3
|
+
rvimage/domain.py,sha256=iFV5Yd3lqmSNtakwIkHZ-1LE47FiQ2PLFaFom5eRsUU,2996
|
4
|
+
rvimage-0.1.0.dist-info/METADATA,sha256=YnR6nV_vUejxRuRBeNHfacbb3UE8lZtUCGiineBXs-4,613
|
5
|
+
rvimage-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
rvimage-0.1.0.dist-info/top_level.txt,sha256=7DS7CkxhgwOOxvcYmMMuOJ8e51SP25t0luO_dxsn2YE,8
|
7
|
+
rvimage-0.1.0.dist-info/RECORD,,
|
rvimage-0.0.1.dist-info/METADATA
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: rvimage
|
3
|
-
Version: 0.0.1
|
4
|
-
Summary: Add your description here
|
5
|
-
Requires-Python: >=3.12
|
6
|
-
Description-Content-Type: text/markdown
|
7
|
-
Requires-Dist: opencv-python-headless>=4.11.0.86
|
8
|
-
Requires-Dist: pydantic>=2.11.7
|
9
|
-
Requires-Dist: scipy>=1.15.3
|
rvimage-0.0.1.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
rvimage/collection_types.py,sha256=Jt0iefceOnOkCwEZFPGhb_aIeZQXG8mYwVtSGTBamV0,3492
|
2
|
-
rvimage/converters.py,sha256=gBHgknXMuAVQnB6birZKXdFMFnbouv88QKba3JAiSPA,2578
|
3
|
-
rvimage/domain.py,sha256=iFV5Yd3lqmSNtakwIkHZ-1LE47FiQ2PLFaFom5eRsUU,2996
|
4
|
-
rvimage-0.0.1.dist-info/METADATA,sha256=CI8wLKpuSsOFc7LcrU0m6t6aA-9ttmui6pAJk3V35BM,260
|
5
|
-
rvimage-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
rvimage-0.0.1.dist-info/top_level.txt,sha256=7DS7CkxhgwOOxvcYmMMuOJ8e51SP25t0luO_dxsn2YE,8
|
7
|
-
rvimage-0.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|