--- pretty_name: corn1000 — counted cereal kernels on A4 license: cc-by-nc-4.0 language: - en size_categories: - n<1K tags: - agriculture - counting - object-counting - cereal - grain - thousand-kernel-weight configs: - config_name: default data_files: - split: test path: data/test/** - split: train path: data/train/** --- # corn1000 — counted cereal kernels on A4 Photos of cereal kernels spread on a white A4 sheet, each labelled with the **exact number of kernels** on the sheet. The dataset is built to train models that count kernels from a single phone photo, as the first step of estimating the thousand-kernel weight (TKW = mass ÷ count × 1000). A 1 % count error is a 1 % TKW error, so the collection protocol is built around label correctness. ## Contents | | | |---|---| | Images | 853 | | Arrangements (distinct kernel layouts) | 150 | | Kernels per image | 170 – 800 | | Images with point annotations | 28 | | Splits | test: 131, train: 722 | | Session | Species | Lot | Light | Chaff | Cameras | Images | Arrangements | Kernels | |---|---|---|---|---|---|---|---|---| | S01 | rye-w | rye-w-A | desk | light | Galaxy S23, iPhone 8 | 108 | 27 | 274–787 | | S02 | oats-s | oats-s-A | desk | none | Galaxy S23, iPhone 8 | 124 | 31 | 240–798 | | S03 | barley-w | barley-w-A | desk | light | Galaxy S23, Galaxy Tab S6 Lite, iPhone 8 | 225 | 28 | 225–733 | | S04 | wheat-w | wheat-w-A | desk | light | Galaxy Tab S6 Lite, Pixel 9 | 131 | 33 | 170–800 | | S05 | durum-w | durum-w-A | desk | light | Galaxy S23, iPhone 8 | 265 | 31 | 230–782 | ## Fields | Column | Meaning | |---|---| | `image` | The photo. JPEG; see *Orientation* below. | | `count` | Number of kernels on the sheet — the label. | | `arrangement_id` | One physical layout of kernels (`-[-]`). Every arrangement is photographed several times, see *Splitting*. | | `session`, `step`, `take` | Session ID, card number within the session, and re-shoot number after a REDO. | | `species` | `rye-w` winter rye, `durum-w` winter durum wheat, `barley-w` winter barley, `oats-s` spring oats, `wheat-w` winter soft wheat. | | `lot` | Seed lot the kernels come from. | | `light` | Lighting setup of the session (free text). | | `chaff` | `none`, `light` or `heavy`: amount of chaff, awns and broken kernels mixed in. **Never counted.** | | `camera` | Camera model from EXIF. | | `taken_at` | Capture time from EXIF (camera clock, no time zone). | | `weight_g` | Mass of the counted kernels in grams, only where they were weighed; else empty. | | `tkw_g` | `weight_g ÷ count × 1000`, where `weight_g` exists. | | `raw_file` | Path of the original raw file in this repo (`raw/…`) if the photo was shot as DNG; else empty. | | `kernel_points` | `[x, y]` of every counted kernel, see *Point annotations*; null if the photo is not annotated. | | `broken_points` | `[x, y]` of broken kernels (not counted); null if not annotated. | | `invalid_points` | `[x, y]` of other objects marked as not countable; null if not annotated. | ## How it was collected ### Counting rules Based on ISO 520:2010. **Counts as a kernel:** an intact kernel, including shrivelled and small ones. Barley and oats count with their husk. Twins count as two kernels. **Never counts:** broken kernels; chaff, straw and awns; foreign seeds, dust and stones. Borderline cases were sorted out rather than judged, to keep the count exact. **Chaff and broken kernels in the data:** they will occur in the use case, so some sessions deliberately contain them as noise (`chaff` = `light` or `heavy`). They are never part of `count`. ### Materials - White A4 sheet on a dark or high-contrast background - Cups for the kernels, each holding a verified 50 kernels - Printed session cards and special cards (REDO, INVALIDATE) from the planning script - Optional: a gram scale ### Procedure Each session covers one species, one seed lot, one lighting setup and one chaff level, and follows a pre-generated plan of about 30 session cards. Each card carries a QR code and states the new total and what to add or remove (`add 17`, `remove 12`, `add 1 cup + 9`). 1. Take the next session card and put the stated number of kernels on the A4 sheet. 2. **If the card says CHECK:** recount the kernels. - The count matches the large number on the card: continue. - It does not: photograph an *INVALIDATE* card and fix the pile until it matches the card. 3. Photograph the session card. 4. Spread the kernels on the sheet so that no piles remain; touching is fine. 5. Photograph the layout twice per phone, with the whole A4 sheet in frame: first roughly top-down, then tilted or from another distance. 6. **If the kernels are weighed:** photograph the scale display, filling the frame, straight on. 7. Next card. If something goes wrong within a card, a *REDO* card is photographed, the pile is fixed to the number on the current card, and the card and the layout are photographed again. ### Variation between sessions Lighting (window light, desk lamp, cold and warm light, morning and evening), phones (see the table above) and backgrounds (table, mat, tray, floor). ### Sessions - **S01:** winter rye (`rye-w-A`), light chaff, desk light; Galaxy S23 and iPhone 8; 2026-09-15/16. - **S02:** spring oats (`oats-s-A`), no chaff, desk light; Galaxy S23 and iPhone 8; 2026-10-02. - **S03:** winter barley (`barley-w-A`), light chaff, desk light; Galaxy S23 (shot as DNG), iPhone 8 and Galaxy Tab S6 Lite; shot over three days, 2026-09-16 to 09-21. The only weighed session. - **S04:** winter soft wheat (`wheat-w-A`), light chaff, desk light; Pixel 9 and Galaxy Tab S6 Lite; 2026-10-15. Test data. The tablet missed or misdated the photos of cards 0, 3, 8, 14 and 15; its photos of those layouts were placed on the card by hand and checked against the Pixel photos. ### Labelling A script decodes the card photos and assigns their total to the photos that follow them. It checks that every total follows from the previous one and the card's delta. A group whose chain breaks (a skipped or unread card) stays *suspect* until the next CHECK, and groups before an INVALIDATE are *invalidated*. **Only groups whose chain validated are in this dataset**, after a review of every group by eye. Card photos and scale photos are not included. ## Splitting Images are **not independent**: every arrangement appears in 2–22 photos (several phones, several angles), and consecutive arrangements of a session share most of their kernels. Split by `lot`, or at least by `session`; never by image, and never by `arrangement_id` alone. The intended evaluation holds out winter soft wheat (`wheat-w`) entirely, plus at least one lot of every training species. The `test` split follows that rule. ## Loading ```python from datasets import load_dataset ds = load_dataset("SmartFarmingLab/corn1000") ``` **Orientation:** most JPEGs are stored sideways with an EXIF orientation tag, exactly as the phones wrote them. `datasets`, browsers and `cv2.imread` apply the tag; plain `PIL.Image.open` does not — call `PIL.ImageOps.exif_transpose` after it. **Raw photos:** some phones shot DNG. For those, the image in `data/` was developed with LibRaw (rawpy, camera white balance, full resolution, JPEG quality 95). The originals are in `raw/`, linked by `raw_file`. Colours of developed DNGs differ from the phones' own JPEG processing. ## Point annotations A subset of photos carries one point per object, placed by hand in CVAT. Coordinates are pixels of the **upright** image, i.e. after the EXIF orientation is applied (what `datasets` returns), with the origin at the top left. The points are a second, independent annotation: `len(kernel_points)` can differ from `count` by a few kernels, mostly on dense sheets where a kernel was missed or lies at the edge of the frame. `count` stays the label. ## Known limitations - Only the species and lots in the table above so far. - Some sessions contain chaff and broken kernels (`chaff` ≠ `none`). They are visible in the photos and deliberately not part of the count. ## Contributing New sessions are welcome. **Do not upload photos to this repository directly.** Every file here is generated by the export script from reviewed labels; photos without a `metadata.jsonl` row have no count and are useless for training. The tools are in the [project repository](https://github.com/SmartFarmingLab/corn1000) (private, access on request from the Smart Farming Lab). 1. **Plan:** `tools/plan_session.py --species … --lot … --light … --chaff …` writes `sessions//plan.json` and the cards to print. Keep `plan.json`: it is the reference the labels are checked against. 2. **Shoot** the session as described under [Procedure](#procedure). 3. **Label:** copy the original files (not via a messenger) to `sessions//` and run `tools/sort_photos.py sessions/ --out labels/`. 4. **Review** every group in `labels//review.html` and mark the checked rows `review=done` in `labels.csv`. 5. **Hand in** `plan.json`, `labels//` and the original photos to the maintainers (the photos are too large for git). They run the export and upload the session here. ## License [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/): free to use and adapt for non-commercial purposes with attribution. For commercial use, contact the Smart Farming Lab (Universität Leipzig). ## Citation No publication yet.