# DeepHS Fruit: hyperspectral fruit ripeness (avocado, kaki, kiwi, mango, papaya)

## Facts

- Provider: Universität Tübingen, Cognitive Systems Group
- License: No license file published by the source. Distributed openly via direct HTTP + a BitTorrent mirror for research use; cite Varga et al., "Measuring the Ripeness of Fruit with Hyperspectral Imaging and Deep Learning" (IJCNN 2021) and the GitHub repo. Confirm terms with the authors before any commercial use.
- Records: annotations/*_v2.json (use these, not the unsuffixed 2021 files)
- Stored at: cogsys.cs.uni-tuebingen.de
- Access: public, readable without an account
- Category: Agriculture & Environment
- Source: https://github.com/cogsys-tuebingen/deephs_fruit
- Page: https://scigantic.com/archive/83d67f92-0eac-5bcd-bade-80c28849c490
- Keywords: Agriculture & Environment

## About

DeepHS Fruit is the University of Tübingen Cognitive Systems group's hyperspectral fruit-ripeness dataset: 5,307 hyperspectral recordings of individual avocado, kaki, kiwi, mango and papaya specimens, captured over multi-day post-harvest storage with three registered camera systems (Specim FX10 VIS, INNOSPEC RedEye NIR, Corning microHSI 410 VIS-NIR) so every specimen has up to three co-registered spectral cubes. 1,018 of the recordings carry destructive ground truth (initial/end weight, firmness, storage days, a 3-class ripeness_state plus a finer-grained ripeness_state_fine) from val/test/train_only_labeled; the remaining ~4,300 train_all recordings are unlabeled and intended for self-supervised pretraining. This entry mounts the publisher's own HTTP tree read-only via rclone (lazy HTTP range reads, nothing copied) rather than a Scigantic-managed mirror, so the archive always reflects the upstream release, including the 2024-01-09 corrected annotation set. Each fruit's cubes ship as one ENVI .hdr/.bin pair per capture, inside a per-fruit zip (Avocado.zip 72G, Kiwi.zip 44G, Papaya.zip 22G, Mango.zip 2.7G, Kaki.zip 2.2G); rclone's HTTP mount + Python's zipfile support lazy range reads into individual members without extracting the whole zip. See the schema card for the exact records/annotations JSON join and camera band tables.

## Load the data

```python
import io, json, os, zipfile
import numpy as np
import pandas as pd

root = os.path.expanduser("~/archive")

# 1) Build a records+annotations dataframe from the CORRECTED (v2) val split.
with zipfile.ZipFile(f"{root}/annotations-upd-2024-01-09.zip") as zf:
    d = json.load(zf.open("annotations/val_v2.json"))
records = pd.DataFrame(d["records"])
annotations = pd.DataFrame(d["annotations"])
df = records.merge(annotations, left_on="id", right_on="record_id", suffixes=("_rec", "_ann"))
print(df[["fruit", "camera_type", "day", "ripeness_state", "firmness"]].head())

# 2) Lazily read ONE hyperspectral cube out of a 72GB fruit zip (no full download —
#    the rclone http mount serves range reads, zipfile only fetches this member).
row = records[(records.fruit == "Avocado") & (records.camera_type == "VIS")].iloc[0]
with zipfile.ZipFile(f"{root}/Avocado.zip") as zf:
    hdr_bytes = zf.read(row["files"]["header_file"])
    bin_bytes = zf.read(row["files"]["data_file"])
# hdr_bytes is the ENVI header (ASCII, key=value); parse with `spectral.io.envi` or by hand
# to get samples/lines/bands, then np.frombuffer(bin_bytes, dtype=...).reshape(...).
```

Written for a Scigantic notebook, where /mnt/archive (SCIGANTIC_MOUNT_PATH) is the mounted dataset.

## Data structure

| Field | Type |
| --- | --- |
| `cameras[].id` | string — "VIS" \| "NIR" \| "VIS_COR" |
| `cameras[].name` | string — "Specim FX10" (VIS) \| "INNOSPEC RedEye" (NIR) \| "Corning microHSI 410 Vis-NIR Hyperspectral Sensor" (VIS_COR) |
| `cameras[].wavelengths` | float[] — per-band center wavelength in nm. VIS: 224 bands, 397.66-1003.81nm. NIR: 252 bands, 919.68-1727.04nm.… |
| `records[].id` | int — join key to annotations[].record_id |
| `records[].fruit` | string — "Avocado" \| "Kaki" \| "Kiwi" \| "Mango" \| "Papaya" |
| `records[].side` | string — which face of the specimen was imaged, e.g. "front" \| "back" |
| `records[].day` | string — post-harvest storage day folder id; naming convention varies by fruit, do not parse, use verbatim |
| `records[].camera_type` | string — "VIS" \| "NIR" \| "VIS_COR", matches cameras[].id |
| `records[].files.header_file` | string — relative path to the ENVI .hdr sidecar inside the fruit zip |
| `records[].files.data_file` | string — relative path to the ENVI .bin cube inside the fruit zip |
| `annotations[].record_id` | int — FK to records[].id. NOTE: destructive measurements are physically per-SPECIMEN, but this table has one row per… |
| `annotations[].init_weight / end_weight` | number, grams — specimen weight at day 0 and at the annotated day |
| `annotations[].storage_days` | int — days elapsed since harvest/day 0 at the time of this measurement |
| `annotations[].firmness` | number — penetrometer-style firmness reading (higher = firmer; units/instrument not stated by the source, treat as… |
| `annotations[].ripeness_state` | string — 3-class label: "unripe" \| "perfect" \| "overripe". THE primary classification target. |
| `annotations[].ripeness_state_fine` | string — finer-grained ripeness label alongside ripeness_state |
| `annotations[].comment` | string \| null — free-text annotator note, usually null |

Files:

```text
Two layers. Top level (rclone-mounted at ~/archive and $SCIGANTIC_MOUNT_PATH) is 5 per-fruit
zips plus 2 annotation zips, served straight from the university HTTP server — nothing pre-extracted:
  Avocado.zip (72G)  Kiwi.zip (44G)  Papaya.zip (22G)  Mango.zip (2.7G)  Kaki.zip (2.2G)
  annotations.zip (166K, 2021 labels)  annotations-upd-2024-01-09.zip (166K, corrected labels — USE THIS ONE)

Inside each fruit zip, already rooted at "<Fruit>/" (no manual renaming needed):
  <Fruit>/<camera_type>/<day_folder>/<fruit>_<day_folder>_<idx>_<side>.hdr
  <Fruit>/<camera_type>/<day_folder>/<fruit>_<day_folder>_<idx>_<side>.bin
camera_type is one of VIS | NIR | VIS_COR (3 separate co-registered camera systems, see columns).
day_folder naming is NOT uniform across fruits — Kaki verified as "day_9_m3" (batch-suffixed),
other fruits use plain "day_03" style. Always resolve the real relative path from the JSON
records[].files object (below), never assume the naming convention.

Inside each annotation zip: 4 splits x 2 schema versions = 8 JSON files
  annotations/{train_all,train_only_labeled,val,test}.json        (2021 schema, v1)
  annotations/{train_all,train_only_labeled,val,test}_v2.json     (2022 schema, v2 — corrected)
Each JSON is one dict with 4 top-level keys: info, cameras (3 camera specs incl. per-band
wavelengths), records (one row per capture, id/fruit/side/day/camera_type/files), and
annotations (one row per record_id, the destructive ripeness measurements).
```

Example file: `Kaki/VIS/day_9_m3/kaki_day_9_m3_25_back.bin (verified via a 184,840-byte Range-read central-directory scan of the 2.2GB Kaki.zip, not a download) — sibling .hdr is the ENVI header.`

## Open it

- In a hosted notebook with the data mounted: https://scigantic.com/archive/83d67f92-0eac-5bcd-bade-80c28849c490
- Full record as JSON (schema card included): https://api.scigantic.com/api/archives/83d67f92-0eac-5bcd-bade-80c28849c490
- Over MCP: `get_schema_card` with id `83d67f92-0eac-5bcd-bade-80c28849c490` at https://api.scigantic.com/mcp

## Related topics

- [Agriculture & Environment datasets](https://scigantic.com/topics/agriculture-and-environment)
