Skip to content

Commit c15899c

Browse files
committed
add text for ocr
1 parent 19aeb59 commit c15899c

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

clarifai/runners/utils/data_types/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
from .data_types import Concept # noqa
44
from .data_types import Frame # noqa
55
from .data_types import Image # noqa
6-
from .data_types import Mask # noqa
76
from .data_types import MessageData # noqa
87
from .data_types import NamedFields # noqa
98
from .data_types import NamedFieldsMeta # noqa
10-
from .data_types import Point # noqa
119
from .data_types import Region # noqa
1210
from .data_types import Text # noqa
1311
from .data_types import Video # noqa

clarifai/runners/utils/data_types/data_types.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,14 @@ def from_proto(cls, proto: PointProto) -> "Point":
284284

285285
class Region(MessageData):
286286

287-
def __init__(
288-
self,
289-
proto_region: RegionProto = None,
290-
box: List[float] = None,
291-
concepts: List[Concept] = None,
292-
mask: Union[Mask, 'Image', PILImage.Image, np.ndarray] = None,
293-
point: Union[Point, Tuple[float, float, float]] = None,
294-
track_id: str = None,
295-
):
287+
def __init__(self,
288+
proto_region: RegionProto = None,
289+
box: List[float] = None,
290+
concepts: List[Concept] = None,
291+
mask: Union[Mask, 'Image', PILImage.Image, np.ndarray] = None,
292+
point: Union[Point, Tuple[float, float, float]] = None,
293+
track_id: str = None,
294+
text: str = None):
296295
if proto_region is None:
297296
proto_region = RegionProto()
298297
self.proto = proto_region
@@ -306,7 +305,17 @@ def __init__(
306305
if point:
307306
self.point = point
308307
if track_id:
309-
self.track_id
308+
self.track_id = track_id
309+
if text:
310+
self.text = text
311+
312+
@property
313+
def text(self):
314+
return self.proto.data.text.raw
315+
316+
@text.setter
317+
def text(self, value: str):
318+
self.proto.data.text.raw = value
310319

311320
@property
312321
def box(self) -> List[float]:

0 commit comments

Comments
 (0)