Dataset Viewer
Auto-converted to Parquet
Search is not available for this dataset
The dataset viewer is not available for this split.
Rows from parquet row groups are too big to be read: 380.33 MiB (max=286.10 MiB)
Error code:   TooBigContentError

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Living Optics Hyperspectral Fruit Dataset

Overview

This dataset contains 100 images of various fruits and vegetables captured under controlled lighting, with the Living Optics Camera.

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.

An additional 11 labelled images are provided as a validation set.

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 training dataset contains 19 classes:

  • πŸ‹ lemon - 8275 total spectral samples
  • 🍈 melon - 9507 total spectral samples
  • πŸ₯’ cucumber - 227 total spectral samples
  • 🍏 granny smith apple - 3984 total spectral samples
  • 🍏 jazz apple - 272 total spectral samples
  • 🍎 plastic apple - 6693 total spectral samples
  • 🍎 pink lady apple - 17311 total spectral samples
  • 🍎 royal gala apple - 21319 total spectral samples
  • πŸ… tomato - 3748 total spectral samples
  • πŸ… cherry tomato - 360 total spectral samples
  • πŸ… plastic tomato - 569 total spectral samples
  • πŸ«‘ green pepper - 226 total spectral samples
  • πŸ«‘ yellow pepper - 4752 total spectral samples
  • πŸ«‘ orange pepper - 552 total spectral samples
  • 🍊 orange - 4641 total spectral samples
  • 🍊 easy peeler orange - 2720 total spectral samples
  • 🍐 pear - 194 total samples
  • πŸ‡ green grape - 106 total spectral samples
  • πŸ‹β€πŸŸ© lime - 43 total spectral samples

Requirements

Download instructions

You can access this dataset via the Living Optics Cloud Portal.

See our Spatial Spectral ML project for an example of how to train and run a segmentation and spectral classification algoirthm using this dataset.

Usage

import os
import numpy as np
import matplotlib.pyplot as plt
from lo_dataset_reader import DatasetReader, spectral_coordinate_indices_in_mask, rle_to_mask

os.environ["QT_QPA_PLATFORM"] = "xcb"

dataset_path = "/path/to/dataset"
dataset = DatasetReader(dataset_path, display_fig=True)

for idx, ((info, scene, spectra, images_extern), converted_spectra, annotations, library_spectra, labels) in enumerate(dataset):
    for ann_idx, annotation in enumerate(annotations):
        annotation["labels"] = labels

        # Visualise the annotation on the scene
        dataset.save_annotation_visualisation(scene, annotation, images_extern, ann_idx)

        # Get spectrum stats from annotation
        stats = annotation.get("extern", {}).get("stats", {})
        label = stats.get("category")
        mean_radiance_spectrum = stats.get("mean_radiance_spectrum")
        mean_reflectance_spectrum = stats.get("mean_reflectance_spectrum")

        # Get mask and spectral indices
        mask = rle_to_mask(annotation["segmentation"], scene.shape)
        spectral_indices = spectral_coordinate_indices_in_mask(mask, info.sampling_coordinates)

        # Extract spectra and converted spectra
        spec = spectra[spectral_indices, :]
        conv_spec = converted_spectra[spectral_indices, :]

        # X-axis based on band index or wavelengths (optional)
        x = np.arange(spec.shape[1])
        if stats.get("wavelength_min") is not None and stats.get("wavelength_max") is not None:
            x = np.linspace(stats["wavelength_min"], stats["wavelength_max"], spec.shape[1])

        # Create figure and subplots
        fig, axs = plt.subplots(2, 2, figsize=(12, 8))
        
        # (1,1) Individual radiance spectra
        for s in spec:
            axs[0, 0].plot(x, s, alpha=0.3)
        axs[0, 0].set_title("Radiance Spectra")
        axs[0, 0].set_xlabel("Wavelength")
        axs[0, 0].set_ylabel("Radiance")

        # (1,2) Mean + Min/Max (Radiance)
        if mean_radiance_spectrum is not None:
            spec_min = np.min(spec, axis=0)
            spec_max = np.max(spec, axis=0)
            axs[0, 1].fill_between(x, spec_min, spec_max, color='lightblue', alpha=0.5, label='Min-Max Range')
            axs[0, 1].plot(x, mean_radiance_spectrum, color='blue', label='Mean Radiance')
            axs[0, 1].set_title("Extern Mean Β± Range (Radiance)")
            axs[0, 1].set_xlabel("Wavelength")
            axs[0, 1].set_ylabel("Radiance")
            axs[0, 1].legend()

        # (2,1) Individual reflectance spectra
        for s in conv_spec:
            axs[1, 0].plot(x, s, alpha=0.3)
        axs[1, 0].set_title("Reflectance Spectra")
        axs[1, 0].set_xlabel("Wavelength")
        axs[1, 0].set_ylabel("Reflectance")

        # (2,2) Mean + Min/Max (Reflectnace)
        if mean_reflectance_spectrum is not None:
            conv_min = np.min(conv_spec, axis=0)
            conv_max = np.max(conv_spec, axis=0)
            axs[1, 1].fill_between(x, conv_min, conv_max, color='lightgreen', alpha=0.5, label='Min-Max Range')
            axs[1, 1].plot(x, mean_reflectance_spectrum, color='green', label='Mean Reflectance')
            axs[1, 1].set_title("Extern Mean Β± Range (Reflectance)")
            axs[1, 1].set_xlabel("Wavelength")
            axs[1, 1].set_ylabel("Reflectance")
            axs[1, 1].legend()

        fig.suptitle(f"Annotation {label}", fontsize=16)
        
        plt.tight_layout()
        plt.show()  
Downloads last month
387