Skip to content

Instantly share code, notes, and snippets.

@mohan-aditya05
Created July 9, 2023 20:32
Show Gist options
  • Save mohan-aditya05/68ffb9ca164ff85b0a19e17029bfd0fe to your computer and use it in GitHub Desktop.
Save mohan-aditya05/68ffb9ca164ff85b0a19e17029bfd0fe to your computer and use it in GitHub Desktop.
import fiftyone as fo
from fiftyone import ViewField as F
dataset = fo.Dataset("imagenet")
# Using array slicing
range_view = dataset[2:5]
dataset.save_view("range_view", range_view)
# Sort by number of detection in "Detections" field "ground_truth"
sort_view = dataset.sort_by(F("ground_truth.detections").length(), reverse=True)
print(len(view.first().ground_truth.detections)) # 39
print(len(view.last().ground_truth.detections)) # 0
# Populate metadata on all samples
dataset.compute_metadata()
# Samples whose image is less than 48 KB
small_images_view = dataset.match(F("metadata.size_bytes") < 48 * 1024)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment