Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,108 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
task_categories:
|
3 |
+
- image-segmentation
|
4 |
+
- image-classification
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
tags:
|
8 |
+
- agritech
|
9 |
+
- hyperspectral
|
10 |
+
- spectroscopy
|
11 |
+
- fruit
|
12 |
+
- sub-class classification
|
13 |
+
- detection
|
14 |
+
size_categories:
|
15 |
+
- 10K<n<100K
|
16 |
+
license: mit
|
17 |
+
---
|
18 |
+
|
19 |
+
# Living Optics Orchard Dataset
|
20 |
+
## Overview
|
21 |
+
This dataset contains 435 images of captured in one of the UK's largest orchards, using the Living Optics Camera.
|
22 |
+
|
23 |
+
The data consists of RGB images, sparse spectral samples and instance segmentation masks.
|
24 |
+
|
25 |
+
The dataset is derived from 44 unique raw files corresponding to 435 frames.
|
26 |
+
Therefore, multiple frames could originate from the same raw file.
|
27 |
+
This structure emphasized the need for a split strategy that avoided data leakage.
|
28 |
+
To ensure robust evaluation, the dataset was divided using an 8:2 split, with splitting performed at the raw file level rather than the frame level.
|
29 |
+
This strategy guaranteed that all frames associated with a specific raw file were confined to either the training set or the test set, eliminating the
|
30 |
+
risk of overlapping information between the two sets.
|
31 |
+
The dataset contains 3,785 instances of Royal Gala Apples, 2,523 instances of Pears, and 73 instances of Cox Apples, summing to a total of 6,381 labelled instances.
|
32 |
+
|
33 |
+
The spectra which do not lie within a labelled segmentation mask can be used for negative sampling when training classifiers.
|
34 |
+
|
35 |
+
|
36 |
+
Additional unlabelled data is available upon request.
|
37 |
+
|
38 |
+
|
39 |
+
## Classes
|
40 |
+
The training dataset contains 3 classes:
|
41 |
+
- 🍎 cox apple - 3,605 total spectral samples
|
42 |
+
- 🍎 royal gala apple - 13,282 total spectral samples
|
43 |
+
- 🍐 pear - 34,398 total spectral samples
|
44 |
+
|
45 |
+
The remaining 1,855,755 spectra are unlabelled and can be considered a single "background " class.
|
46 |
+
|
47 |
+
## Requirements
|
48 |
+
|
49 |
+
- [lo-sdk](https://www.livingoptics.com/register-for-download-sdk/)
|
50 |
+
- [lo-data](https://huggingface.co/spaces/LivingOptics/README/discussions/3)
|
51 |
+
|
52 |
+
|
53 |
+
## Download instructions
|
54 |
+
|
55 |
+
### Command line
|
56 |
+
```commandline
|
57 |
+
mkdir -p hyperspectral-orchard
|
58 |
+
huggingface-cli download LivingOptics/hyperspectral-orchard --repo-type dataset --local-dir hyperspectral-orchard
|
59 |
+
```
|
60 |
+
|
61 |
+
### Python
|
62 |
+
```python
|
63 |
+
from huggingface_hub import snapshot_download
|
64 |
+
dataset_path = snapshot_download(repo_id="LivingOptics/hyperspectral-orchard", repo_type="dataset")
|
65 |
+
print(dataset_path)
|
66 |
+
```
|
67 |
+
|
68 |
+
## Usage
|
69 |
+
|
70 |
+
```python
|
71 |
+
import os.path as op
|
72 |
+
import numpy.typing as npt
|
73 |
+
from typing import List, Dict, Generator
|
74 |
+
from lo.data.tools import Annotation, LODataItem, LOJSONDataset, draw_annotations
|
75 |
+
from lo.data.dataset_visualisation import get_object_spectra, plot_labelled_spectra
|
76 |
+
from lo.sdk.api.acquisition.io.open import open as lo_open
|
77 |
+
|
78 |
+
# Load the dataset
|
79 |
+
path_to_download = op.expanduser("~/Downloads/hyperspectral-orchard")
|
80 |
+
dataset = LOJSONDataset(path_to_download)
|
81 |
+
|
82 |
+
# Get the training data as an iterator
|
83 |
+
training_data: List[LODataItem] = dataset.load("train")
|
84 |
+
|
85 |
+
# Inspect the data
|
86 |
+
lo_data_item: LODataItem
|
87 |
+
for lo_data_item in training_data[:3]:
|
88 |
+
|
89 |
+
draw_annotations(lo_data_item)
|
90 |
+
|
91 |
+
ann: Annotation
|
92 |
+
for ann in lo_data_item.annotations:
|
93 |
+
print(ann.class_name, ann.category, ann.subcategories)
|
94 |
+
|
95 |
+
# Plot the spectra for each class
|
96 |
+
fig, ax = plt.subplots(1)
|
97 |
+
object_spectra_dict = {}
|
98 |
+
class_numbers_to_labels = {0: "background_class"}
|
99 |
+
for lo_data_item in training_data:
|
100 |
+
object_spectra_dict, class_numbers_to_labels = get_object_spectra(
|
101 |
+
lo_data_item, object_spectra_dict, class_numbers_to_labels
|
102 |
+
)
|
103 |
+
|
104 |
+
plot_labelled_spectra(object_spectra_dict, class_numbers_to_labels, ax)
|
105 |
+
plt.show()
|
106 |
+
```
|
107 |
+
|
108 |
+
See our [Spatial Spectral ML](https://github.com/livingoptics/spatial-spectral-ml) project for an example of how to train and run a segmentation and spectral classification algoirthm using this dataset.
|