Skip to content

Commit

Permalink
Merge pull request #2614 from voxel51/save-ids
Browse files Browse the repository at this point in the history
Always use IDs in plots and brain results
  • Loading branch information
brimoor committed Feb 6, 2023
2 parents 9101ec1 + a6a0eeb commit 85d2f59
Show file tree
Hide file tree
Showing 8 changed files with 859 additions and 595 deletions.
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

0 comments on commit 85d2f59

Please sign in to comment.