File size: 5,618 Bytes
c137e72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dbaa5b2
c137e72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72549b1
c137e72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169

---
license: mit
task_categories:
  - object-detection
  - image-segmentation
  - feature-extraction
  - zero-shot-classification
tags:
  - agriculture
  - coffee
  - food-quality
  - commodity-grading
pretty_name: Pre-Roast Arabica Coffee Bean Grading Dataset
size_categories:
  - 1K<n<10K
---

# An Image Dataset of Pre-Roast Robusta Coffee Beans with Polygon Annotations for Automated Grading

## Abstract
Automated quality assessment of raw agricultural products is critical for ensuring fair trade and supply chain efficiency. This dataset presents **3,877 high-resolution images** of *pre-roast Arabica coffee beans*, collected from farms in **Coorg, Karnataka (India)**—a major coffee-producing region. Each bean is categorized into one of four quality grades:

| Grade | Description |
|-------|-------------|
| A | Premium |
| B | Good |
| C | Standard |
| D | Defective |

A total of **2,284 beans** are annotated using **polygon masks** and grade labels in **LabelMe JSON format**, supporting research in **classification, instance segmentation, automated grading, and defect detection**. A YOLOv11 multi-class instance segmentation baseline was trained to validate annotation quality and demonstrate practical model performance.

---

## Dataset Structure

```text
/
├── CGA/   # Grade A (Premium)
│   ├── CGA_images/
│   └── CGA_json/
├── CGB/   # Grade B (Good)
├── CGC/   # Grade C (Standard)
└── CGD/   # Grade D (Defective)
```


### Distribution Summary

| Grade | Quality | Images | Polygon Annotations |
|-------|---------|--------|---------------------|
| A | Premium | 1000 | 600 |
| B | Good | 1000 | 600 |
| C | Standard | 1002 | 487 |
| D | Defective | 875 | 597 |
| **Total** | — | **3,877** | **2,284** |

---

## Data Collection and Annotation

| Attribute | Details |
|----------|---------|
| Coffee Variety | *Coffea robusta* |
| Region | Coorg (Kodagu), Karnataka, India |
| Imaging Setup | Controlled indoor lighting with a white backdrop |
| Devices Used | iPhone 15 Pro, Samsung 2023/24 models, Google Pixel 7, Poco X Series |
| Annotation Tool | LabelMe (Polygon Mode) |
| Data Format | `.jpg` images + `.json` polygon annotation files |

Each annotation file contains:
* `"label": "grade_a" | "grade_b" | "grade_c" | "grade_d"`
* `"points": [ [x1,y1], [x2,y2], ... ]`

Annotations were reviewed by trained annotators to ensure precision.

---

## Recommended Use Cases

- Multi-class instance segmentation training
- Automated grading and sorting systems
- Agricultural defect detection research
- Food quality assurance studies
- Robust low-cost supply chain inspection systems

### Out-of-Scope Use
- Personal identification
- Medical or biometric inference (dataset contains **no personal data**)

---

## Baseline Experiment (YOLOv11 Segmentation)

To validate the dataset's quality and visual separability, a baseline instance segmentation model (YOLOv11) was trained. The model was trained for 150 epochs, with the best-performing checkpoint saved for evaluation.

The results confirm that the dataset supports strong performance for automated grading, achieving a mean Average Precision (mAP) of **0.93** for object detection and **0.91** for instance segmentation.

### Final Metrics (from `best.pt` model)

| Metric | Grade A | Grade B | Grade C | Grade D | Mean (All Classes) |
|:-------|:--------:|:--------:|:--------:|:--------:|:------:|
| **Box mAP@0.5** | 0.94 | 0.90 | 0.91 | 0.97 | **0.93** |
| **Mask mAP@0.5** | 0.92 | 0.88 | 0.88 | 0.96 | **0.91** |

> **Note:** The high precision on Grade D (Defective) is particularly valuable, as it demonstrates the model's reliability in identifying and sorting out low-quality beans, which is a primary goal of automated grading systems.

---


## How to Use

### Load JSON Annotation Example
```python
import json
import glob

# Example for Grade A
files = glob.glob("CGA/CGA_json/*.json")
with open(files[0], "r") as f:
    ann = json.load(f)

print(ann["shapes"][0]["points"])  # Polygon coordinates
print(ann["shapes"][0]["label"])   # Grade label
````

## Value of the Dataset

  * First publicly available polygon-annotated dataset of pre-roast coffee beans.
  * Enables end-to-end automated grading using segmentation + classification.
  * Facilitates fair pricing and quality transparency in the coffee supply chain.
  * Robust for deployment in low-cost rural environments using consumer smartphones.

## Contributors

| Name | ORCID | Role |
|---|---|---|
| Samruddh K | 0009-0008-3588-9272 | Research, Dataset Preparation & Documentation |
| Abhay Varun S | 0009-0003-1299-724X | Research, Dataset Collection & Annotation |
| Bopanna K N | 0009-0008-0432-3196 | Annotation Support & Verification |
| H A Dheemanth Gowda | 0009-0001-1891-632X | Annotation Support & Verification |


## Citation

If you use this dataset, please cite:

@dataset{pre_roast_coffee_grading_2025,
title = {A Image Dataset of Pre-Roast Arabica Coffee Beans with Polygon Annotations for Automated Grading},
author = {Samruddh K and Bopanna K N and H A Dheemanth Gowda and Abhay Varun S},
year = {2025},
publisher = {Hugging Face Datasets},
license = {MIT},
url = {https://huggingface.co/datasets/SamruddhK/coffee-bean-grading-dataset}
}


## Contact

For questions, collaborations, or research use:
- Dataset Maintainer: **Samruddh K & Abhay Varun S**
- Hugging Face: https://huggingface.co/SamruddhK
- GitHub Samruddh K: https://github.com/SAMRUDDH15
- GitHub Abhay Varun S: https://github.com/abhay-error
* **Email:** [samruddh.k52@gmail.com & Abhayvarun618@gmail.com]

<!-- end list -->