nmai
Collection
norwegian national competition in AI • 3 items • Updated
Object detection dataset for Norwegian grocery store shelf images, from the NorgesGruppen Data competition.
from datasets import load_dataset
# COCO format (default) - raw competition annotations
ds = load_dataset("valiantlynxz/norwegian-grocery", trust_remote_code=True)
# YOLO format - auto-converted on load, no scripts needed
ds = load_dataset("valiantlynxz/norwegian-grocery", name="yolo", trust_remote_code=True)
# Product reference images - multi-angle shots per product
ds = load_dataset("valiantlynxz/norwegian-grocery", name="products", trust_remote_code=True)
| Config | Default | Description | Splits |
|---|---|---|---|
coco |
Yes | Raw COCO annotations with full metadata | train, validation |
yolo |
YOLO normalized [cx, cy, w, h] (converted on-the-fly) |
train, validation | |
products |
Product reference images with metadata | train |
Each example contains a shelf image and all its COCO-format annotations:
ds = load_dataset("valiantlynxz/norwegian-grocery", trust_remote_code=True)
example = ds["train"][0]
example["image"] # PIL Image
example["image_id"] # int
example["width"] # image width in pixels
example["height"] # image height in pixels
example["annotations"] # JSON string of COCO annotation list
# Each annotation: {"id", "category_id", "bbox": [x, y, w, h], "area", "product_code", ...}
Same images, but bounding boxes are auto-converted to YOLO normalized center format:
ds = load_dataset("valiantlynxz/norwegian-grocery", name="yolo", trust_remote_code=True)
example = ds["train"][0]
example["image"] # PIL Image
example["image_id"] # int
example["labels"] # [int, ...] - category IDs
example["bboxes"] # [[cx, cy, w, h], ...] - normalized to [0, 1]
Reference images for 327 products, organized by product code:
ds = load_dataset("valiantlynxz/norwegian-grocery", name="products", trust_remote_code=True)
example = ds["train"][0]
example["image"] # PIL Image (one angle)
example["product_code"] # barcode string
example["product_name"] # e.g. "EVERGOOD CLASSIC KOKMALT 250G"
example["image_type"] # "main", "front", "back", "left", "right", "top", "bottom"
example["annotation_count"] # how often this product appears in shelf images
unknown_product)norwegian_grocery.py # Custom loading script (auto-discovered by HF)
train/
annotations.json # COCO-format annotations
images/ # 248 shelf images (.jpg/.jpeg)
NM_NGD_product_images/
metadata.json # Product names, barcodes, annotation counts
{barcode}/ # Product reference images per barcode
scripts/
coco_to_yolo.py # Convert COCO to YOLO format with train/val split
COCO format (annotations.json):
{
"images": [{"id": 1, "file_name": "img_00001.jpg", "width": 2000, "height": 1500}],
"categories": [{"id": 0, "name": "VESTLANDSLEFSA TØRRE 10STK 360G", "supercategory": "product"}],
"annotations": [{
"id": 1, "image_id": 1, "category_id": 42,
"bbox": [141, 49, 169, 152],
"area": 25688, "iscrowd": 0,
"product_code": "8445291513365",
"product_name": "NESCAFE VANILLA LATTE 136G NESTLE",
"corrected": true
}]
}
bbox is [x, y, width, height] in pixels (COCO format).
If you need on-disk YOLO files for ultralytics, the repo includes scripts/coco_to_yolo.py:
python scripts/coco_to_yolo.py \
--annotations train/annotations.json \
--images train/images \
--output yolo \
--val-ratio 0.15
This creates yolo/images/{train,val}/, yolo/labels/{train,val}/, and configs/dataset.yaml.
cd detection/
make data # clones from HuggingFace
make yolo # generates YOLO format + dataset.yaml
unknown_product (355) with 422 annotations