-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Sketch class in forte/data/ontology/top.py * add hash function docstring in Sketch class in forte/data/ontology/top.py * add Sketch class in the __init__ variable in forte/data/ontology/top.py * black * add docstring for 'Sketch' in forte/data/ontology/top.py * add index_key() for 'Sketch' in forte/data/ontology/top.py * black format and add Grids * fix docstring for Sketch in forte/data/ontology/top.py * Sketch -> ImageAnnotation * only keep essential class variables: image_annotations, grids and payloads * remove array data from Grids * minor changes on class variables of Grids * add test cases for grids and image annotation * update docstring in forte/data/ontology/top.py * update grids test * grid_config -> height_n_width and associate Grids to payload * black * correct height_n_width constraint * remove the wrong import * add Grids in __init__ * debugged the parameter issues height_n_width -> height, width two paramters * adjust the test cases accordingly based on code changes * add tests for raise ValueErrror * pylint * pylint: line length * pylint * pylint * remove index_key() and move up super().__init__(pack) * self.height -> self._height and self.width -> self._width * rewrite __eq__() * remove hash function for ImageAnnotation and Grids * keep only one image_payload_idx in Grids and make it required in __init__ * add docstring in get_grid_cell and remove condition for checking image_payload_idx is None * adjust grids test accordingly * update docstring * remove wrong import * Region -> Box -> BoundingBox * example for checking overlapping between bounging boxes * add link between BoundingBox and Text externally * add function compute_iou() for Box and Region * add example code for compute_iou() * remove auto imports and adjust __init__ order * image_annotation and grids: SortedList -> List * add docstrings for BoundingBox related classes * add more definitions for overlapping * update image_payload_idx default values * inline BoundingBox init * inline BoundingBox init * add index definition to more places * add ImageAnnotation to SinglePackEntries * add BoundingBox related ontologies to __init__ * add BoundingBox related ontologies to __init__ * change docstring locations of bounding box related entries * add -> append * SortedList -> List for self.image_annotations and self.grids * add units for indices * fix pylint error
- Loading branch information
Showing
5 changed files
with
292 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import numpy as np | ||
from forte.data.ontology.top import BoundingBox, Link, Annotation | ||
from forte.data.data_pack import DataPack | ||
|
||
datapack = DataPack("image") | ||
|
||
# line = np.zeros((6, 12)) | ||
line = np.zeros((20, 20)) | ||
line[2, 2] = 1 | ||
line[3, 3] = 1 | ||
line[4, 4] = 1 | ||
datapack.payloads.append(line) | ||
datapack.payloads.append(line) | ||
# grid config: 3 x 4 | ||
# grid cell indices: (0, 0) | ||
bb1 = BoundingBox(datapack, 0, 2, 2, 3, 4, 0, 0) | ||
datapack.image_annotations.append(bb1) | ||
# grid config: 3 x 4 | ||
# grid cell indices: (1, 0) | ||
bb2 = BoundingBox(datapack, 0, 2, 2, 3, 4, 1, 0) | ||
datapack.image_annotations.append(bb2) | ||
# grid config: 4 x 4 | ||
# grid cell indices: (1, 0) | ||
bb3 = BoundingBox(datapack, 0, 2, 2, 4, 4, 0, 0) | ||
|
||
print(bb1.is_overlapped(bb2)) | ||
print(bb1.is_overlapped(bb3)) | ||
|
||
datapack.set_text("bb1, bb2, bb3") | ||
bb1_descrip = Annotation(datapack, 0, 3) | ||
|
||
print(bb1_descrip.text) | ||
link1 = Link(datapack, bb1_descrip, bb1) | ||
datapack.add_entry(link1) | ||
print(list(datapack.all_links)) | ||
|
||
print(bb1.compute_iou(bb3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters