eto-ai / rikai

Parquet-based ML data format optimized for working with unstructured data
https://rikai.readthedocs.io/en/latest/
Apache License 2.0
138 stars 19 forks source link

Autoscale geometries #488

Open changhiskhan opened 2 years ago

changhiskhan commented 2 years ago

Currently if we have a relative Box, we need to manually rescale it by the image in order to draw it:

img | [box * (row.height, row.width) for box in row.annotations]

Instead we should consider:

  1. Indicate whether a Box or Polygon is in relative or absolute space.
  2. Add a property in Image to retrieve the shape
  3. Automatically rescale the geometry when drawing
changhiskhan commented 2 years ago

@Renkai if you're looking for something to tackle, this is a good one

changhiskhan commented 2 years ago

One alternative to adding an attribute is we could consider creating a RelativeGeometry mixin that has functionality to autoscale. Then we just create Relative* subclasses of * Geometry classes with the RelativeGeometry mixin added and (hopefully) nothing else. Thoughts? @eddyxu ?

Renkai commented 2 years ago

@changhiskhan Sounds interesting, but I have some questions.

And can you address some links to the key classes or files on how we implement the box drawing mechanism in the current code base?

da-liii commented 2 years ago

Key python file: https://github.com/eto-ai/rikai/blob/main/python/rikai/viz.py

da-liii commented 2 years ago

Mixin: https://github.com/eto-ai/rikai/blob/main/python/rikai/mixin.py

https://github.com/eto-ai/rikai/blob/fed57cd7d22b520b87c1a6693850916051ba9331/python/rikai/types/vision.py#L44

Rikai Image depends on Mixins heavily.

da-liii commented 2 years ago

Here is a related issue: https://github.com/eto-ai/rikai/issues/523

These DSL should be designed at the very beginning. And then we start to implement it.

da-liii commented 2 years ago

I found that the box2d returned by AWS Rekognition (e.g. recognize celebrities) is relative box2d.