Skip to content
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

DataPack function to Retrieve overlapped ImageAnnotation using data structure grid #888

Open
hepengfe opened this issue Jul 25, 2022 · 5 comments
Assignees
Labels
topic:cv topic: data Issue about data loader modules and data processing related

Comments

@hepengfe
Copy link
Collaborator

hepengfe commented Jul 25, 2022

Is your feature request related to a problem? Please describe.
One of the main reasons for creating grid is to searching overlapped ImageAnnotation efficiently. However, the current code supports compute iou but not search overlapped ImageAnnotation.

Describe the solution you'd like

  • store a grid in the DataPack
  • store two dictionaries in the DataPack based on the grid
    • dictionary 1: key is grid cell position and value is a collection of image annotation presented at the grid cell
    • dictionary 2: key is the image annotation and value is a list of grid cell positions it's on
  • implement a function that search overlapped ImageAnnnotation given a ImageAnnnotation using the two dictionaries
grid_cells = dict2[query_ia]
image_anns = set()
for gc in grid_cells:
     for ia in dict1[gc]:
        image_anns.add(ia)

out = []
for ia in  image_anns:
     if ia.overlap(query_ia):
        out.append(ia)

return ia

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
This is a follow-up issue on #876 (comment)

@hepengfe hepengfe added topic: data Issue about data loader modules and data processing related topic:cv labels Jul 25, 2022
@hepengfe hepengfe self-assigned this Jul 25, 2022
@hunterhector
Copy link
Member

Actually, this is not what we discussed, we don't want users to manually compute any IOU, they should be able to do something like "a_box.iou(a_circle)". So what we need here is not a tutorial.

  1. We want to have a system interanlly to manage stuff like overlap/covering, we don't ask the users to write an algorithm for it. Please make a comparison to the text datapack system, where we can do something like sentence.get(Token). Most of the time the user don't have to interact with the Grid object, just like they don't have to interact with the Span object.
  2. Please be careful and precise of the wording, we don't compute "overlapped images", we are computing overalp between ImageAnnotation

@mylibrar

@mylibrar
Copy link
Collaborator

Actually, this is not what we discussed, we don't want users to manually compute any IOU, they should be able to do something like "a_box.iou(a_circle)". So what we need here is not a tutorial.

  1. We want to have a system interanlly to manage stuff like overlap/covering, we don't ask the users to write an algorithm for it. Please make a comparison to the text datapack system, where we can do something like sentence.get(Token). Most of the time the user don't have to interact with the Grid object, just like they don't have to interact with the Span object.
  2. Please be careful and precise of the wording, we don't compute "overlapped images", we are computing overalp between ImageAnnotation

@mylibrar

Then maybe we should update the title and content of this issue. It should be targeted at implementing some internal algorithms for calculating overlap/covering between ImageAnnotations instead of creating a new tutorial/example.

@hunterhector
Copy link
Member

hunterhector commented Jul 25, 2022

Actually, this is not what we discussed, we don't want users to manually compute any IOU, they should be able to do something like "a_box.iou(a_circle)". So what we need here is not a tutorial.

  1. We want to have a system interanlly to manage stuff like overlap/covering, we don't ask the users to write an algorithm for it. Please make a comparison to the text datapack system, where we can do something like sentence.get(Token). Most of the time the user don't have to interact with the Grid object, just like they don't have to interact with the Span object.
  2. Please be careful and precise of the wording, we don't compute "overlapped images", we are computing overalp between ImageAnnotation

@mylibrar

Then maybe we should update the title and content of this issue. It should be targeted at implementing some internal algorithms for calculating overlap/covering between ImageAnnotations instead of creating a new tutorial/example.

The prioritization of this item can be determined according to other items. This item is a stretch goal for the last quarter. Our final goal is to provide computation among arbitrary image annotations, and the defined goal for last quarter is for regular shapes only, like #802

@hepengfe
Copy link
Collaborator Author

I think currently our implementation can already compute overlapping between ImageAnnotation here

def compute_iou(self, other) -> float:
.

For support like region.get(Box), we can build a grid in the DataPack and a dictionary stores image annotation presenting at each grid cell.

@hepengfe hepengfe changed the title Create a tutorial to check overlap between irregular shapes using data structure grid DataPack function to Retrieve overlapped ImageAnnotation using data structure grid Jul 25, 2022
@hunterhector
Copy link
Member

  • Please be careful and precise of the wording, we don't compute "overlapped images", we are computing overalp between ImageAnnota

Yeah, that means we don't need the tutorial of how to do these for scratch, but it is valuable to show how to use these functions.

For simple get with regular shapes, we can do it easily. For irregular shapes, we then need to use Grid.

However, most of the supports for irregular shapes are not in our current scope, let's do them later. As for now, if operations involve those, we should throw some NotImplementedError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:cv topic: data Issue about data loader modules and data processing related
Projects
None yet
Development

No branches or pull requests

3 participants