Skip to content

Instantly share code, notes, and snippets.

@ehofesmann
Last active October 5, 2022 16:42
Show Gist options
  • Save ehofesmann/41481dd0b91e0b1a42435b8a07a76cf9 to your computer and use it in GitHub Desktop.
Save ehofesmann/41481dd0b91e0b1a42435b8a07a76cf9 to your computer and use it in GitHub Desktop.
import fiftyone as fo
import fiftyone.zoo as foz
from fiftyone import ViewField as F
# Add random geolocation data as detection attributes for this example
import random
dataset = foz.load_zoo_dataset("quickstart")
for sample in dataset:
for det in sample.ground_truth.detections:
det["det_loc"] = fo.GeoLocation(
point=[random.uniform(-180,180), random.uniform(-90,90)]
)
sample.save()
# Add a sample field that we can set in the future
dataset.add_sample_field("location", ftype=fo.EmbeddedDocumentField, embedded_doc_type=fo.GeoLocation)
# Create a patches view, make sure to carry of the location field added previously
view = dataset.to_patches("ground_truth", other_fields="location")
# Temporarily set the values of the "location" field to the corresponding detection location attribute for each patch
view = view.set_field("location", F("ground_truth.det_loc"))
session = fo.launch_app(view)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment