task_categories:image-classification size_categories:10K<n<100K language:en license:mit biology medical region:us
---
license: mit
task_categories:
- image-classification
language:
- en
tags:
- biology
- medical
pretty_name: HEp-2 Cell
size_categories:
- 10K<n<100K
# dataset_info:
#   splits:
#   - name: train
#     num_examples: 10876
#   - name: validation
#     num_examples: 1360
#   - name: test
#     num_examples: 1360
---

# Dataset card for "george-chou/HEp2"
## Usage
### Print
```
from datasets import load_dataset

data = load_dataset("george-chou/HEp2")
trainset = data["train"]
validset = data["validation"]
testset = data["test"]
labels = trainset.features["label"].names

for item in trainset:
    print("image: ", item["image"])
    print("label name: " + labels[item["label"]])

for item in validset:
    print("image: ", item["image"])
    print("label name: " + labels[item["label"]])

for item in testset:
    print("image: ", item["image"])
    print("label name: " + labels[item["label"]])
```

### Use on Torch DataLoader
```
import torch
from datasets import load_dataset
from torch.utils.data import DataLoader
from torchvision.transforms import *

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

compose = Compose([
    Resize(300),
    CenterCrop(300),
    RandomAffine(5),
    ToTensor(),
    Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])


def transform(example_batch):
    inputs = [compose(x.convert("RGB")) for x in example_batch["image"]]
    example_batch["image"] = inputs
    return example_batch


ds = load_dataset("george-chou/HEp2")
trainset = ds["train"].with_transform(transform)
validset = ds["validation"].with_transform(transform)
testset = ds["test"].with_transform(transform)

traLoader = DataLoader(trainset, batch_size=4)
valLoader = DataLoader(validset, batch_size=4)
tesLoader = DataLoader(testset, batch_size=4)

for i, data in enumerate(traLoader, 0):
    inputs, labels = data["image"].to(device), data["label"].to(device)
    print("inputs: ", inputs)
    print("labels: ", labels)

for i, data in enumerate(valLoader, 0):
    inputs, labels = data["image"].to(device), data["label"].to(device)
    print("inputs: ", inputs)
    print("labels: ", labels)

for i, data in enumerate(tesLoader, 0):
    inputs, labels = data["image"].to(device), data["label"].to(device)
    print("inputs: ", inputs)
    print("labels: ", labels)
```

## Maintenance
```
git clone git@hf.co:datasets/george-chou/HEp2
```