|
|
---
|
|
|
license: mit
|
|
|
task_categories:
|
|
|
- image-classification
|
|
|
tags:
|
|
|
- food
|
|
|
- vegetables
|
|
|
- fruits
|
|
|
- recognition
|
|
|
- classification
|
|
|
- raw-food
|
|
|
- educational
|
|
|
size_categories:
|
|
|
- 10K<n<100K
|
|
|
---
|
|
|
|
|
|
# Merged Raw Food Recognition Dataset
|
|
|
|
|
|
## Dataset Description
|
|
|
|
|
|
This dataset is a comprehensive compilation of three publicly available food recognition datasets, merged and curated for raw food recognition tasks. The dataset contains images of various raw food items including fruits, vegetables, dairy products, and beverages, intended for educational purposes and the development of image recognition models.
|
|
|
|
|
|
### Purpose
|
|
|
|
|
|
This dataset is created for **educational purposes only** to support research and learning in computer vision and food recognition applications.
|
|
|
|
|
|
## Dataset Statistics
|
|
|
|
|
|
- **Total Classes**: 90+ food categories
|
|
|
- **Total Images**: ~15,000+ images
|
|
|
- **Train/Validation Split**: 80/20 ratio
|
|
|
- **Image Format**: JPEG/PNG
|
|
|
- **Image Resolution**: Variable (typically 224x224 or higher)
|
|
|
|
|
|
## Dataset Structure
|
|
|
|
|
|
The dataset is organized into train and validation splits:
|
|
|
|
|
|
- **train**: 80% of the data (~12,000 images)
|
|
|
- **validation**: 20% of the data (~3,000 images)
|
|
|
|
|
|
Each sample contains:
|
|
|
- `image`: PIL Image object of the food item
|
|
|
- `label`: String label indicating the food category (e.g., "apple", "banana", "carrot")
|
|
|
- `label_id`: Integer ID corresponding to the label (0 to num_classes-1)
|
|
|
|
|
|
## Source Datasets
|
|
|
|
|
|
This merged dataset combines images from the following three sources:
|
|
|
|
|
|
### 1. Food and Vegetables Dataset
|
|
|
- **Source**: [SunnyAgarwal4274/Food_and_Vegetables](https://huggingface.co/datasets/SunnyAgarwal4274/Food_and_Vegetables)
|
|
|
- **Description**: A collection of food and vegetable images for classification tasks
|
|
|
- **License**: Please refer to the original dataset repository
|
|
|
|
|
|
### 2. Fruit and Vegetable Image Recognition Dataset
|
|
|
- **Source**: [Nattakarn/fruit-and-vegetable-image-recognition](https://huggingface.co/datasets/Nattakarn/fruit-and-vegetable-image-recognition)
|
|
|
- **Description**: A dataset focused on fruit and vegetable recognition
|
|
|
- **License**: Please refer to the original dataset repository
|
|
|
|
|
|
### 3. Grocery Store Dataset
|
|
|
- **Source**: [Kaggle - Grocery Store Dataset](https://www.kaggle.com/datasets/validmodel/grocery-store-dataset/data)
|
|
|
- **Description**: A comprehensive grocery store product dataset including various food items
|
|
|
- **License**: Please refer to the original Kaggle dataset license
|
|
|
|
|
|
## Merging Process
|
|
|
|
|
|
The datasets were merged using the following methodology:
|
|
|
|
|
|
1. **Data Collection**: Images from all three source datasets were collected and organized by food category
|
|
|
2. **Label Standardization**: Food categories were standardized across datasets (e.g., "yogurt" and "yoghurt" variants were preserved as separate classes to maintain dataset diversity)
|
|
|
3. **Deduplication**: Duplicate images were identified and removed where possible
|
|
|
4. **Class Consolidation**: Similar food items were grouped into consistent categories
|
|
|
5. **Stratified Splitting**: The merged dataset was split into training (80%) and validation (20%) sets using stratified sampling to maintain class distribution
|
|
|
6. **Format Conversion**: Images were converted to a unified format suitable for HuggingFace Datasets and saved in Parquet format for efficient storage and access
|
|
|
|
|
|
## Food Categories
|
|
|
|
|
|
The dataset includes the following categories (sample):
|
|
|
|
|
|
- **Fruits**: apple, banana, orange, strawberry, grapes, mango, kiwi, watermelon, etc.
|
|
|
- **Vegetables**: carrot, tomato, potato, onion, broccoli, cauliflower, spinach, etc.
|
|
|
- **Dairy Products**: milk, yogurt (various flavors), sour cream, etc.
|
|
|
- **Beverages**: apple juice, orange juice, grapefruit juice, soy milk, oat milk, etc.
|
|
|
- **Specialty Items**: Various gourds (bottle gourd, bitter gourd, ridge gourd), exotic fruits (dragon fruit, passion fruit), etc.
|
|
|
|
|
|
For a complete list of all 90+ categories, please refer to the dataset's class mapping file.
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
### Loading the Dataset
|
|
|
|
|
|
```python
|
|
|
from datasets import load_dataset
|
|
|
|
|
|
# Load the dataset
|
|
|
dataset = load_dataset("your-username/dataset-name")
|
|
|
|
|
|
# Access train and validation splits
|
|
|
train_dataset = dataset['train']
|
|
|
val_dataset = dataset['validation']
|
|
|
|
|
|
# Example: Get a sample
|
|
|
sample = train_dataset[0]
|
|
|
image = sample['image']
|
|
|
label = sample['label']
|
|
|
label_id = sample['label_id']
|
|
|
```
|
|
|
|
|
|
### Using with PyTorch
|
|
|
|
|
|
```python
|
|
|
from datasets import load_dataset
|
|
|
from torch.utils.data import DataLoader
|
|
|
import torchvision.transforms as transforms
|
|
|
|
|
|
# Load dataset
|
|
|
dataset = load_dataset("your-username/dataset-name")
|
|
|
|
|
|
# Define transforms
|
|
|
transform = transforms.Compose([
|
|
|
transforms.Resize((224, 224)),
|
|
|
transforms.ToTensor(),
|
|
|
transforms.Normalize(mean=[0.485, 0.456, 0.406],
|
|
|
std=[0.229, 0.224, 0.225])
|
|
|
])
|
|
|
|
|
|
# Apply transforms
|
|
|
def transform_image(examples):
|
|
|
examples['image'] = [transform(img.convert('RGB')) for img in examples['image']]
|
|
|
return examples
|
|
|
|
|
|
train_dataset = dataset['train'].with_transform(transform_image)
|
|
|
val_dataset = dataset['validation'].with_transform(transform_image)
|
|
|
|
|
|
# Create data loaders
|
|
|
train_loader = DataLoader(train_dataset, batch_size=32, shuffle=True)
|
|
|
val_loader = DataLoader(val_dataset, batch_size=32, shuffle=False)
|
|
|
```
|
|
|
|
|
|
### Using with TensorFlow/Keras
|
|
|
|
|
|
```python
|
|
|
from datasets import load_dataset
|
|
|
import tensorflow as tf
|
|
|
|
|
|
# Load dataset
|
|
|
dataset = load_dataset("your-username/dataset-name")
|
|
|
|
|
|
# Convert to TensorFlow format
|
|
|
train_tf = dataset['train'].to_tf_dataset(
|
|
|
columns=['image'],
|
|
|
label_cols=['label_id'],
|
|
|
batch_size=32,
|
|
|
shuffle=True
|
|
|
)
|
|
|
```
|
|
|
|
|
|
## Dataset Characteristics
|
|
|
|
|
|
- **Diversity**: Images from multiple sources ensure diversity in lighting, backgrounds, and image quality
|
|
|
- **Class Balance**: Stratified splitting maintains class distribution across train/validation splits
|
|
|
- **Real-world Variability**: Includes natural variations in food appearance, ripeness, and presentation
|
|
|
- **Educational Focus**: Curated specifically for learning and research purposes
|
|
|
- **Parquet Format**: Data is stored in Parquet format for efficient storage and fast loading
|
|
|
|
|
|
## Limitations and Considerations
|
|
|
|
|
|
1. **Class Imbalance**: Some food categories may have more samples than others
|
|
|
2. **Image Quality**: Images come from different sources with varying quality and resolution
|
|
|
3. **Label Variants**: Some food items have multiple label variants (e.g., "yogurt" vs "yoghurt") preserved for dataset diversity
|
|
|
4. **Educational Purpose**: This dataset is intended for educational use only
|
|
|
|
|
|
## Citation
|
|
|
|
|
|
If you use this dataset in your research or educational projects, please cite the original source datasets:
|
|
|
|
|
|
```bibtex
|
|
|
@dataset{food_recognition_merged,
|
|
|
title={Merged Raw Food Recognition Dataset},
|
|
|
author={Your Name},
|
|
|
year={2024},
|
|
|
note={Combined from: SunnyAgarwal4274/Food_and_Vegetables,
|
|
|
Nattakarn/fruit-and-vegetable-image-recognition,
|
|
|
and Kaggle Grocery Store Dataset}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## License
|
|
|
|
|
|
This dataset is provided for **educational purposes only**. Please refer to the original source datasets for their respective licenses and terms of use.
|
|
|
|
|
|
## Acknowledgments
|
|
|
|
|
|
We gratefully acknowledge the creators and contributors of the source datasets:
|
|
|
- SunnyAgarwal4274 for the Food and Vegetables dataset
|
|
|
- Nattakarn for the Fruit and Vegetable Image Recognition dataset
|
|
|
- The Kaggle community for the Grocery Store Dataset
|
|
|
|
|
|
## Contact
|
|
|
|
|
|
For questions or issues regarding this dataset, please open an issue in the repository.
|
|
|
|
|
|
## Updates
|
|
|
|
|
|
- **2024**: Initial release with 90+ food categories and 80/20 train/validation split in Parquet format
|
|
|
|
|
|
|