-
Notifications
You must be signed in to change notification settings - Fork 59
Ocr showcase #866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ocr showcase #866
Changes from all commits
2e156e2
b94097b
4f156ab
793c35c
aa7427d
6f76e2f
054b4af
514c17c
969c4b4
313e570
1f7211a
d06d21d
ccbe2e6
9a0f0ad
ba2e9c3
91a2bda
55a4e89
5589d63
f00cafb
6c2d598
9794cfd
1386f8d
7725fec
5cd139d
a67baa2
f85b456
eafb17c
045392d
add6582
e0ea6fa
3f4d32a
388da05
8eddea4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ | |
|
||
import numpy as np | ||
from sortedcontainers import SortedList | ||
|
||
from forte.common.exception import ( | ||
ProcessExecutionException, | ||
UnknownOntologyClassException, | ||
|
@@ -47,13 +46,13 @@ | |
from forte.data.ontology.core import EntryType | ||
from forte.data.ontology.top import ( | ||
Annotation, | ||
Grids, | ||
Link, | ||
Group, | ||
SinglePackEntries, | ||
Generics, | ||
AudioAnnotation, | ||
ImageAnnotation, | ||
Grids, | ||
Payload, | ||
) | ||
|
||
|
@@ -171,8 +170,8 @@ def __init__(self, pack_name: Optional[str] = None): | |
self._data_store: DataStore = DataStore() | ||
self._entry_converter: EntryConverter = EntryConverter() | ||
self.image_annotations: List[ImageAnnotation] = [] | ||
self.grids: List[Grids] = [] | ||
|
||
self.grids: List[Grids] = [] | ||
self.text_payloads: List[Payload] = [] | ||
self.audio_payloads: List[Payload] = [] | ||
self.image_payloads: List[Payload] = [] | ||
|
@@ -244,7 +243,7 @@ def text(self) -> str: | |
@property | ||
def audio(self) -> Optional[np.ndarray]: | ||
r"""Return the audio of the data pack""" | ||
return self.get_payload_data_at(Modality.Audio, 0) | ||
return cast(np.ndarray, self.get_payload_data_at(Modality.Audio, 0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a typing issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I don't think we should assume |
||
|
||
@property | ||
def all_annotations(self) -> Iterator[Annotation]: | ||
|
@@ -448,15 +447,12 @@ def get_payload_at( | |
supported_modality = [enum.name for enum in Modality] | ||
|
||
try: | ||
# if modality.name == "text": | ||
if modality == Modality.Text: | ||
payloads_length = len(self.text_payloads) | ||
payload = self.text_payloads[payload_index] | ||
# elif modality.name == "audio": | ||
elif modality == Modality.Audio: | ||
payloads_length = len(self.audio_payloads) | ||
payload = self.audio_payloads[payload_index] | ||
# elif modality.name == "image": | ||
elif modality == Modality.Image: | ||
payloads_length = len(self.image_payloads) | ||
payload = self.image_payloads[payload_index] | ||
|
@@ -569,7 +565,7 @@ def set_text( | |
# temporary solution for backward compatibility | ||
# past API use this method to add a single text in the datapack | ||
if len(self.text_payloads) == 0 and text_payload_index == 0: | ||
from ft.onto.base_ontology import ( # pylint: disable=import-outside-toplevel | ||
from ft.onto.payload_ontology import ( # pylint: disable=import-outside-toplevel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we importing locally here, these should be imported top level |
||
TextPayload, | ||
) | ||
|
||
|
@@ -601,7 +597,7 @@ def set_audio( | |
# temporary solution for backward compatibility | ||
# past API use this method to add a single audio in the datapack | ||
if len(self.audio_payloads) == 0 and audio_payload_index == 0: | ||
from ft.onto.base_ontology import ( # pylint: disable=import-outside-toplevel | ||
from ft.onto.payload_ontology import ( # pylint: disable=import-outside-toplevel | ||
AudioPayload, | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"name": "payload_ontology", | ||
"definitions": [ | ||
{ | ||
"entry_name": "ft.onto.payload_ontology.AudioPayload", | ||
"parent_entry": "forte.data.ontology.top.Payload", | ||
"description": "A payload that caches audio data", | ||
"attributes":[ | ||
{ | ||
"name": "sample_rate", | ||
"type": "int" | ||
} | ||
] | ||
}, | ||
{ | ||
"entry_name": "ft.onto.payload_ontology.TextPayload", | ||
"parent_entry": "forte.data.ontology.top.Payload", | ||
"description": "A payload that caches text data", | ||
"attributes": [] | ||
}, | ||
{ | ||
"entry_name": "ft.onto.payload_ontology.ImagePayload", | ||
"parent_entry": "forte.data.ontology.top.Payload", | ||
"description": "A payload that caches image data", | ||
"attributes":[] | ||
}, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's make the indent aligned. |
||
"entry_name": "ft.onto.payload_ontology.JpegMeta", | ||
"parent_entry": "forte.data.ontology.top.Meta", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add the description for these types |
||
"attributes":[ | ||
{ | ||
"name": "extension", | ||
"type": "str" | ||
}, | ||
{"name": "mime", | ||
"type": "str"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just use a json formatter |
||
{"name": "type_code", | ||
"type": "str"}, | ||
{"name": "version", | ||
"type": "str"} | ||
] | ||
}, | ||
{ | ||
"entry_name": "ft.onto.payload_ontology.AudioMeta", | ||
"parent_entry": "forte.data.ontology.top.Meta", | ||
"attributes":[ | ||
{ | ||
"name": "sample_rate", | ||
"type": "int" | ||
}, | ||
{"name": "channels", | ||
"type": "int"}, | ||
{"name": "bits_per_sample", | ||
"type": "int"}, | ||
{"name": "duration", | ||
"type": "float"}, | ||
{"name": "bitrate", | ||
"type": "int"}, | ||
{"name": "encoding", | ||
"type": "str"}, | ||
{"name": "dtype", | ||
"type": "str"} | ||
] | ||
}, | ||
{ | ||
"entry_name": "ft.onto.payload_ontology.JpegPayload", | ||
"parent_entry": "ft.onto.payload_ontology.ImagePayload", | ||
"attributes":[ | ||
{ | ||
"name": "meta", | ||
"type": "ft.onto.payload_ontology.JpegMeta" | ||
} | ||
] | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grids
is still an entry? I thought we discuss that it should be a data structure. Or is that change not merged?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not merged yet and it's in #827