File size: 3,561 Bytes
ad182f3
 
 
 
 
 
 
 
 
 
 
 
 
 
c5ac579
ad182f3
 
 
 
 
 
 
e33af0a
ad182f3
f7f8ece
22bd5e9
 
ad182f3
 
e33af0a
228340e
 
 
 
e33af0a
 
228340e
 
 
 
 
 
 
 
 
 
 
 
 
 
ad182f3
 
 
 
 
228340e
ad182f3
 
 
 
 
 
d4af7a3
 
ad182f3
 
 
 
 
228340e
d4af7a3
ad182f3
 
 
 
 
 
 
 
19ec0f2
 
ad182f3
19ec0f2
ad182f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22bd5e9
 
 
eadfb73
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
task_categories:
- image-segmentation
- image-classification
language:
- en
tags:
- agritech
- hyperspectral
- spectroscopy
- fruit
- sub-class classification
- detection
size_categories:
- 10K<n<100K
---
# Living Optics Orchard Dataset
## Overview
This dataset contains 100 images of various fruits and vegetables captured under controlled lighting, with the [Living Optics Camera](livingoptics.com).

The data consists of RGB images, sparse spectral samples and instance segmentation masks.

From the 100 images, we extract >430,000 spectral samples, of which >85,000 belong to one of the 19 classes in the dataset. The rest of the spectra can be used for negative sampling when training classifiers.

Additionally, we provide a set of demo videos in `.lo` format which are unannotated but which can be used to qualititively test algorithms built on this dataset.


### Classes

The dataset contains 19 classes:
 - lemon - 8275 total samples
 - melon - 9507 total samples
 - yellow pepper - 4752 total samples
 - cucumber - 227 total samples
 - granny smith apple - 3984 total samples
 - jazz apple - 272 total samples
 - plastic apple - 6693 total samples
 - pink lady apple - 17311 total samples
 - royal gala apple - 21319 total samples
 - tomato - 3748 total samples
 - cherry tomato - 360 total samples
 - plastic tomato - 569 total samples
 - green pepper - 226 total samples
 - orange - 4641 total samples
 - easy peeler orange - 2720 total samples
 - orange pepper - 552 total samples
 - pear - 194 total samples
 - green grape - 106 total samples
 - lime - 43 total samples


## Requirements

- [lo-sdk](https://www.livingoptics.com/register-for-download-sdk/)
- [lo-examples](https://github.com/livingoptics/python-examples)
- [lo-data] TODO


## Download instructions

### Command line
```commandline
mkdir -p hyperspectral-fruit
huggingface-cli download LivingOptics/hyperspectral-fruit --repo-type dataset --local-dir hyperspectral-fruit
```

### Python
```python 
from huggingface_hub import hf_hub_download
dataset_path = hf_hub_download(repo_id="LivingOptics/hyperspectral-fruit", filename="train", repo_type="dataset")
print(dataset_path)
```

## Usage

```python
import os.path as op
import numpy.typing as npt
from typing import List, Dict, Generator
from lo.data.tools import Annotation, LODataItem, LOJSONDataset, draw_annotations
from lo.data.dataset_visualisation import get_object_spectra, plot_labelled_spectra
from lo.sdk.api.acquisition.io.open import open as lo_open

# Load the dataset
path_to_download = op.expanduser("~/Downloads/LivingOpticsOrchardData")
dataset = LOJSONDataset(path_to_download)

# Get the training data as an iterator 
training_data: List[LODataItem] = dataset.load("train")

# Inspect the data
lo_data_item: LODataItem
for lo_data_item in training_data[:3]:

    draw_annotations(lo_data_item)

    ann: Annotation
    for ann in lo_data_item.annotations:
        print(ann.class_name, ann.category, ann.subcategories)

# Plot the spectra for each class
fig, ax = plt.subplots(1)
object_spectra_dict = {}
class_numbers_to_labels = {0: "background_class"}
for lo_data_item in training_data:
    object_spectra_dict, class_numbers_to_labels = get_object_spectra(
        lo_data_item, object_spectra_dict, class_numbers_to_labels
    )

plot_labelled_spectra(object_spectra_dict, class_numbers_to_labels, ax)
plt.show()    
```

See [here TODO](https://github.com/livingoptics/python-examples) for an example of how to train and run a segmentation and spectral classification algoirthm using this dataset.