Skip to content

Commit

Permalink
Feat (explorer view): Simplify UI (#237)
Browse files Browse the repository at this point in the history
* feat: add doc_url filed to metrics

* style: remove commented codes

* feat: point to main doc page if attribute does not exist

* feat: do not show any link if doc_url is empty

* fix: change default doc_url value

* feat: update docs and example_metric
  • Loading branch information
Gorkem-Encord authored Mar 8, 2023
1 parent b650711 commit 27a9f72
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/docs/metrics/write-your-own.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ to the awesome paper that proposed the method.
Or use math to better explain such method:
$$h_{\lambda}(x) = \frac{1}{x^\intercal x}$$
""",
doc_url='link/to/documentation', # This is optional, if a link is given, it can be accessed from the app
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=[AnnotationType.OBJECT.BOUNDING_BOX, AnnotationType.OBJECT.ROTATABLE_BOUNDING_BOX, AnnotationType.OBJECT.POLYGON],
Expand Down
7 changes: 4 additions & 3 deletions src/encord_active/app/data_quality/sub_pages/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ def build(self, selected_df: DataFrame[MetricSchema], metric_scope: MetricScope)
if not selected_metric:
return

st.markdown(f"# {self.title}")
st.markdown(f"## {selected_metric.meta.title}")
st.markdown(selected_metric.meta.long_description)
if selected_metric.meta.doc_url is None:
st.markdown(f"### {selected_metric.meta.title}")
else:
st.markdown(f"### [{selected_metric.meta.title}]({selected_metric.meta.doc_url})")

if selected_df.empty:
return
Expand Down
1 change: 1 addition & 0 deletions src/encord_active/lib/metrics/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self):
Or use math to better explain such method:
$$h_{\lambda}(x) = \frac{1}{x^\intercal x}$$
""",
doc_url="link/to/documentation", # This is optional, if a link is given, it can be accessed from the app
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, threshold: float = 0.6):
long_description=r"""Ranks annotations by how likely they are to represent the same object.
> [Jaccard similarity coefficient](https://en.wikipedia.org/wiki/Jaccard_index)
is used to measure closeness of two annotations.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#annotation-duplicates",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down
1 change: 1 addition & 0 deletions src/encord_active/lib/metrics/geometric/hu_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self):
long_description=r"""Computes the Euclidean distance between the polygons'
[Hu moments](https://en.wikipedia.org/wiki/Image_moment) for each class and
the prototypical class moments.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#shape-outlier-detection",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[AnnotationType.OBJECT.POLYGON],
Expand Down
1 change: 1 addition & 0 deletions src/encord_active/lib/metrics/geometric/hu_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self):
long_description=r"""Ranks objects by how similar they are to their instances in previous frames
based on [Hu moments](https://en.wikipedia.org/wiki/Image_moment). The more an object's shape changes,
the lower its score will be.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#polygon-shape-similarity",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.SEQUENCE,
annotation_type=[AnnotationType.OBJECT.POLYGON],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self):
title="Annotation closeness to image borders",
short_description="Ranks annotations by how close they are to image borders.",
long_description=r"""This metric ranks annotations by how close they are to image borders.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#polygon-shape-similarity",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down
4 changes: 4 additions & 0 deletions src/encord_active/lib/metrics/geometric/object_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self):
title="Object Area - Relative",
short_description="Computes object area as a percentage of total image area.",
long_description=r"""Computes object area as a percentage of total image area.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#polygon-shape-similarity",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down Expand Up @@ -68,6 +69,7 @@ def __init__(self):
title="Frame object density",
short_description="Computes the percentage of image area that's occupied by objects.",
long_description=r"""Computes the percentage of image area that's occupied by objects.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#polygon-shape-similarity",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down Expand Up @@ -111,6 +113,7 @@ def __init__(self):
title="Object Area - Absolute",
short_description="Computes object area in amount of pixels",
long_description=r"""Computes object area in amount of pixels.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#object-area---absolute",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down Expand Up @@ -151,6 +154,7 @@ def __init__(self):
title="Object Aspect Ratio",
short_description="Computes aspect ratios of objects",
long_description=r"""Computes aspect ratios ($width/height$) of objects.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#object-aspect-ratio",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
short_description="Tracks objects and detect outliers",
long_description=r"""This metric collects information related to object size and aspect ratio for each track
and find outliers among them.""",
doc_url="https://encord-active-docs.web.app/metrics/geometric#detect-occlusion-in-video",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.SEQUENCE,
annotation_type=[AnnotationType.OBJECT.BOUNDING_BOX, AnnotationType.OBJECT.ROTATABLE_BOUNDING_BOX],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, threshold: float = 0.8):
`Cat:2` will be flagged as potentially having a broken track, because track ids `1` and `2` doesn't match.
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#inconsistent-object-classification-and-track-ids",
metric_type=MetricType.HEURISTIC,
data_type=DataType.SEQUENCE,
annotation_type=[
Expand Down
7 changes: 7 additions & 0 deletions src/encord_active/lib/metrics/heuristic/img_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self):
Contrast is computed as the standard deviation of the pixel values.
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#contrast",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.NONE,
Expand All @@ -49,6 +50,7 @@ def __init__(
short_description=f"Ranks images by how {color_name.lower()} the average value of the image is.",
long_description=f"""Ranks images by how {color_name.lower()} the average value of the
image is.""",
doc_url=f"https://encord-active-docs.web.app/metrics/heuristic/#{color_name.lower()}-values",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.NONE,
Expand Down Expand Up @@ -138,6 +140,7 @@ def __init__(self):
Brightness is computed as the average (normalized) pixel value across each image.
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#brightness",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.NONE,
Expand All @@ -163,6 +166,7 @@ def __init__(self):
score = cv2.Laplacian(image, cv2.CV_64F).var()
```
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#sharpness",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.NONE,
Expand All @@ -188,6 +192,7 @@ def __init__(self):
score = 1 - cv2.Laplacian(image, cv2.CV_64F).var()
```
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#blur",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.NONE,
Expand All @@ -207,6 +212,7 @@ def __init__(self):
Aspect ratio is computed as the ratio of image width to image height ($\frac{width}{height}$).
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#aspect-ratio",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.NONE,
Expand All @@ -231,6 +237,7 @@ def __init__(self):
Area is computed as the product of image width and image height ($width \times height$).
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#area",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.NONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __init__(self, threshold: float = 0.5):
```
`CAT:2` will be marked as potentially having a wrong track id.
""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#missing-objects-and-broken-tracks",
metric_type=MetricType.HEURISTIC,
data_type=DataType.SEQUENCE,
annotation_type=[
Expand Down
1 change: 1 addition & 0 deletions src/encord_active/lib/metrics/heuristic/object_counting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self):
title="Object Count",
short_description="Counts number of objects in the image",
long_description=r"""Counts number of objects in the image.""",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#object-count",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=AnnotationType.ALL,
Expand Down
2 changes: 2 additions & 0 deletions src/encord_active/lib/metrics/heuristic/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self):
title="Random Values on Images",
short_description="Assigns a random value between 0 and 1 to images",
long_description="Uses a uniform distribution to generate a value between 0 and 1 to each image",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#random-values-on-images",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=[],
Expand All @@ -34,6 +35,7 @@ def __init__(self):
title="Random Values on Objects",
short_description="Assigns a random value between 0 and 1 to objects",
long_description="Uses a uniform distribution to generate a value between 0 and 1 to each object",
doc_url="https://encord-active-docs.web.app/metrics/heuristic#random-values-on-objects",
metric_type=MetricType.HEURISTIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down
5 changes: 5 additions & 0 deletions src/encord_active/lib/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class MetricMetadata(BaseModel):
data_type: DataType
annotation_type: List[AnnotationTypeUnion]
embedding_type: Optional[EmbeddingType] = None
doc_url: Optional[str] = None
stats: StatsMetadata

def get_unique_name(self):
Expand All @@ -82,6 +83,7 @@ def __init__(
data_type: DataType,
annotation_type: List[Union[ObjectShape, ClassificationType]],
embedding_type: Optional[EmbeddingType] = None,
doc_url: Optional[str] = None,
):
self.metadata = MetricMetadata(
title=title,
Expand All @@ -91,6 +93,7 @@ def __init__(
data_type=data_type,
annotation_type=annotation_type,
embedding_type=embedding_type,
doc_url=doc_url,
stats=StatsMetadata(),
)

Expand All @@ -109,6 +112,7 @@ def __init__(
data_type: DataType,
annotation_type: List[Union[ObjectShape, ClassificationType]] = [],
embedding_type: Optional[EmbeddingType] = None,
doc_url: Optional[str] = None,
):
self.metadata = MetricMetadata(
title=title,
Expand All @@ -118,6 +122,7 @@ def __init__(
data_type=data_type,
annotation_type=annotation_type,
embedding_type=embedding_type,
doc_url=doc_url,
stats=StatsMetadata(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, near_duplicate_threshold=0.97):
- **To delete duplicate images:** You can set the quality filter to cover only zero values (that ends up with all the duplicate images), then use bulk tagging (e.g., with a tag like `Duplicate`) to tag all images.
- **To mark duplicate images:** Near duplicate images are shown side by side. Navigate through these images and mark whichever is of interest to you.
""",
doc_url="https://encord-active-docs.web.app/metrics/semantic#image-singularity",
metric_type=MetricType.SEMANTIC,
data_type=DataType.IMAGE,
embedding_type=EmbeddingType.CLASSIFICATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, num_nearest_neighbors: int = 10, certainty_ratio: float = 0.6
long_description=r"""This metric creates embeddings from images. Then, these embeddings are used to build
nearest neighbor graph. Similar embeddings' classifications are compared against each other.
""",
doc_url="https://encord-active-docs.web.app/metrics/semantic#image-level-annotation-quality",
metric_type=MetricType.SEMANTIC,
data_type=DataType.IMAGE,
annotation_type=[AnnotationType.CLASSIFICATION.RADIO],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, num_nearest_neighbors: int = 10, certainty_ratio: float = 0.6
and an embedding for each bounding box is extracted. Then, these embeddings are compared
with their neighbors. If the neighbors are annotated differently, a low score is given to it.
""",
doc_url="https://encord-active-docs.web.app/metrics/semantic#object-annotation-quality",
metric_type=MetricType.GEOMETRIC,
data_type=DataType.IMAGE,
annotation_type=[
Expand Down
1 change: 1 addition & 0 deletions src/encord_active/lib/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def load_metric_metadata(meta_pth) -> MetricMetadata:
metric_type=old_meta.get("metric_type", old_meta.get("index_type")),
embedding_type=old_meta.get("embedding_type", None),
annotation_type=annotation_type,
doc_url=old_meta.get("doc_url", None),
stats=stats,
)
with meta_pth.open("w") as f:
Expand Down

0 comments on commit 27a9f72

Please sign in to comment.