NimaBoscarino commited on
Commit
7d2f693
1 Parent(s): 85f035b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +50 -0
README.md CHANGED
@@ -44,6 +44,7 @@ pretty_name: LILA Camera Traps
44
  - [Discussion of Biases](#discussion-of-biases)
45
  - [Other Known Limitations](#other-known-limitations)
46
  - [Additional Information](#additional-information)
 
47
  - [Dataset Curators](#dataset-curators)
48
  - [Licensing Information](#licensing-information)
49
  - [Citation Information](#citation-information)
@@ -474,6 +475,55 @@ N/A
474
 
475
  ## Additional Information
476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
477
  ### Dataset Curators
478
 
479
  LILA BC is maintained by a working group that includes representatives from Ecologize, Zooniverse, the Evolving AI Lab, Snapshot Safari, and Microsoft AI for Earth. Hosting on Microsoft Azure is provided by Microsoft AI for Earth.
 
44
  - [Discussion of Biases](#discussion-of-biases)
45
  - [Other Known Limitations](#other-known-limitations)
46
  - [Additional Information](#additional-information)
47
+ - [Usage](#dataset-usage)
48
  - [Dataset Curators](#dataset-curators)
49
  - [Licensing Information](#licensing-information)
50
  - [Citation Information](#citation-information)
 
475
 
476
  ## Additional Information
477
 
478
+ ### Working with Taxonomies
479
+
480
+ All the taxonomy categories are saved as ClassLabels, which can be converted to strings as needed. Strings can likewise be converted to integers as needed, to filter the dataset. In the example below we filter the "Caltech Camera Traps" dataset to find all the entries with a "felis catus" as the species for the first annotation.
481
+
482
+ ```python
483
+ dataset = load_dataset("society-ethics/lila_camera_traps", "Caltech Camera Traps", split="train")
484
+ taxonomy = dataset.features["annotations"].feature["taxonomy"]
485
+
486
+ # Filters to show only cats
487
+ cats = dataset.filter(lambda x: x["annotations"]["taxonomy"][0]["species"] == taxonomy["species"].str2int("felis catus"))
488
+ ```
489
+
490
+ The original common names have been saved with their taxonomy mappings in this repository in `common_names_to_tax.json`. These can be used, for example, to map from a taxonomy combination to a common name to help make queries more legible. Note, however, that there is a small number of duplicate common names with different taxonomy values which you will need to disambiguate.
491
+
492
+ The following example loads the first "sea turtle" in the "Island Conservation Camera Traps" dataset.
493
+
494
+ ```python
495
+ LILA_COMMON_NAMES_TO_TAXONOMY = pd.read_json("https://huggingface.co/datasets/society-ethics/lila_camera_traps/raw/main/data/common_names_to_tax.json", lines=True).set_index("common_name")
496
+ dataset = load_dataset("society-ethics/lila_camera_traps", "Island Conservation Camera Traps", split="train")
497
+ taxonomy = dataset.features["annotations"].feature["taxonomy"]
498
+
499
+ sea_turtle = LILA_COMMON_NAMES_TO_TAXONOMY.loc["sea turtle"].to_dict()
500
+ sea_turtle = {k: taxonomy[k].str2int(v) if v is not None else v for k, v in sea_turtle.items()} # Map to ClassLabel integers
501
+
502
+ sea_turtle_dataset = ds.filter(lambda x: x["annotations"]["taxonomy"][0] == sea_turtle)
503
+ ```
504
+
505
+ The example below selects a random item from the dataset, and then maps from the taxonomy to a common name:
506
+
507
+ ```python
508
+ LILA_COMMON_NAMES_TO_TAXONOMY = pd.read_json("https://huggingface.co/datasets/society-ethics/lila_camera_traps/raw/main/data/common_names_to_tax.json", lines=True).set_index("common_name")
509
+
510
+ dataset = load_dataset("society-ethics/lila_camera_traps", "Caltech Camera Traps", split="train")
511
+ taxonomy = dataset.features["annotations"].feature["taxonomy"]
512
+
513
+ random_entry = dataset.shuffle()[0]
514
+ filter_taxonomy = random_entry["annotations"]["taxonomy"][0]
515
+
516
+ filter_keys = list(map(lambda x: (x[0], taxonomy[x[0]].int2str(x[1])), filter(lambda x: x[1] is not None, list(filter_taxonomy.items()))))
517
+
518
+ if len(filter_keys) > 0:
519
+ print(LILA_COMMON_NAMES_TO_TAXONOMY[np.logical_and.reduce([
520
+ LILA_COMMON_NAMES_TO_TAXONOMY[k] == v for k,v in filter_keys
521
+ ])])
522
+ else:
523
+ print("No common name found for the item.")
524
+ ```
525
+
526
+
527
  ### Dataset Curators
528
 
529
  LILA BC is maintained by a working group that includes representatives from Ecologize, Zooniverse, the Evolving AI Lab, Snapshot Safari, and Microsoft AI for Earth. Hosting on Microsoft Azure is provided by Microsoft AI for Earth.