hkanade's picture
Update README.md
6e34066 verified
---
license: apache-2.0
task_categories:
- image-feature-extraction
- image-classification
- image-to-image
- text-to-image
size_categories:
- n<1K
tags:
- humans
- glasses
- eyewear
- retrieval
---
# 📸 Persons with Spectacles
A curated image dataset of human faces annotated for the presence of spectacles (eyeglasses).
---
## Dataset Card for `hkanade/persons_with_spectacles`
| **Feature** | **Detail** |
|-----------------------|----------------------------------------------------------------------|
| **Dataset name** | `persons_with_spectacles` |
| **Repository** | https://huggingface.co/datasets/hkanade/persons_with_spectacles |
| **License** | apache-2.0 |
| **Languages** | — |
| **Tasks** | Text to Image, Image classification |
| **Size** | 120 |
| **File format** | Parquet |
| **Dataset version** | 1.0.0 |
---
## 1. Dataset Source
All samples were collected from wikimedia/wit_base.
---
## 2. Usage
```python
from datasets import load_dataset
from PIL import Image
import os
import matplotlib.pyplot as plt
import math, itertools
import io
from IPython.display import display
import cv2
# load full dataset
ds = load_dataset("hkanade/persons_with_spectacles")
def rec_to_pil(rec):
"""
Accepts either
• dict/StructValue holding the raw bytes, or
• raw bytes themselves, or
• a PIL.Image already
Returns a PIL.Image.Image
"""
if isinstance(rec, Image.Image):
return rec # already a PIL image
if isinstance(rec, (bytes, bytearray)):
return Image.open(io.BytesIO(rec))
if isinstance(rec, dict): # pandas case
# try common key names – adjust if yours differ
for k in ("bytes", "data", 0):
if k in rec:
return Image.open(io.BytesIO(rec[k]))
# fall‑back: take first value
return Image.open(io.BytesIO(next(iter(rec.values()))))
# pyarrow StructValue when you skip .to_pandas()
if hasattr(rec, "values"): # StructValue → tuple
return Image.open(io.BytesIO(rec.values()[0]))
raise TypeError(f"Unsupported type: {type(rec)}")
plt.imshow(rec_to_pil(ds["train"][0]["image"]))
plt.plot()
```
---
## 3. Columns
| Column | Datatype | Description |
| --------------------------------- | ---------------------------------------- | ------------------------------------------ |
| `Image` | `struct<bytes: binary, path: string>` | Image |
| `image_url` | `string` | URL of the Wikipedia page |
| `embedding` | `fixed_size_list<element: double>[2048]` | ResNet‑50 embedding |
| `caption_attribution_description` | `string` | Caption text |
| `clip_emb` | `fixed_size_list<element: float>[512]` | CLIP embedding of the image |
| `h` | `fixed_size_list<element: double>[32]` | Hue‑channel histogram |
| `s` | `fixed_size_list<element: double>[32]` | Saturation‑channel histogram |
| `v` | `fixed_size_list<element: double>[32]` | Value‑channel histogram |
| `face_ok` | `bool` | Placeholder flag indicating face validity |
| `sim` | `float` | Cosine similarity with the query embedding |
---
## 4. Citation
```bibtex
@misc{persons_with_spectacles_2025,
author = {Hrishikesh Kanade (hkanade)},
title = {Persons with Spectacles Dataset},
year = {2025},
howpublished = {\url{https://huggingface.co/datasets/hkanade/persons_with_spectacles}}
}
```