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

Always use IDs in plots and brain results #2614

Merged
merged 10 commits into from Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions docs/source/user_guide/plots.rst
Expand Up @@ -361,9 +361,6 @@ contains |GeoLocation| data in its ``location`` field:
dataset = foz.load_zoo_dataset("quickstart-geo")
fob.compute_uniqueness(dataset)

# Index the dataset by visual uniqueness
fob.compute_uniqueness(dataset)

# A list of ``[longitude, latitude]`` coordinates
locations = dataset.values("location.point.coordinates")

Expand Down Expand Up @@ -570,7 +567,6 @@ notebook:
:linenos:

import fiftyone as fo
import fiftyone.core.plots as fop
import fiftyone.zoo as foz
from fiftyone import ViewField as F

Expand All @@ -587,7 +583,7 @@ notebook:
view = dataset.filter_labels("frames.detections", F("label") == "vehicle")

# Plot the number of vehicles in each frame of a video dataset
plot = fop.lines(
plot = fo.lines(
x="frames.frame_number",
y=F("frames.detections.detections").length(),
labels="id",
Expand Down Expand Up @@ -745,7 +741,7 @@ notebook:

# Define some interesting plots
plot1 = fo.NumericalHistogram(F("metadata.size_bytes") / 1024, bins=50, xlabel="image size (KB)")
plot2 = fo.NumericalHistogram("predictions.detections.confidence", bins=50)
plot2 = fo.NumericalHistogram("predictions.detections.confidence", bins=50, range=[0, 1])
plot3 = fo.CategoricalHistogram("ground_truth.detections.label", order="frequency")
plot4 = fo.CategoricalHistogram("predictions.detections.label", order="frequency")

Expand Down
19 changes: 19 additions & 0 deletions fiftyone/core/collections.py
Expand Up @@ -9263,6 +9263,25 @@ def _make_set_field_pipeline(
new_field=new_field,
)

def _get_values_by_id(self, path_or_expr, ids, link_field=None):
if link_field == "frames":
if self._is_frames:
id_path = "id"
else:
id_path = "frames.id"
elif link_field is not None:
_, id_path = self._get_label_field_path(link_field, "id")
elif self._is_patches:
id_path = "sample_id"
else:
id_path = "id"

values_map = {
i: v
for i, v in zip(*self.values([id_path, path_or_expr], unwind=True))
}
return [values_map.get(i, None) for i in ids]


def _unwind_values(values, level=0):
if not values:
Expand Down