Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Quick script to examine the food datasets | |
| """ | |
| import os | |
| from datasets import load_dataset | |
| # Get base directory | |
| base_dir = os.path.dirname(os.path.abspath(__file__)) | |
| print("=" * 60) | |
| print("FOOD DATASETS EXAMINATION") | |
| print("=" * 60) | |
| # Check Food-102 Dataset | |
| print("\n1. FOOD-102 DATASET") | |
| print("-" * 60) | |
| try: | |
| food102_dir = os.path.join(base_dir, 'food102', 'data') | |
| food102_files = [] | |
| if os.path.exists(food102_dir): | |
| for f in os.listdir(food102_dir): | |
| if f.endswith('.parquet'): | |
| food102_files.append(os.path.join(food102_dir, f)) | |
| if food102_files: | |
| # Load just one file to see structure | |
| ds = load_dataset('parquet', data_files=food102_files[:1]) | |
| print(f"β Successfully loaded Food-102 dataset") | |
| print(f" Columns: {ds['train'].column_names}") | |
| print(f" Num samples (in first file): {len(ds['train'])}") | |
| print(f" Total parquet files: {len(food102_files)}") | |
| # Show first sample | |
| sample = ds['train'][0] | |
| print(f" Sample keys: {list(sample.keys())}") | |
| if 'label' in sample: | |
| print(f" Label type: {type(sample['label'])}") | |
| print(f" Sample label: {sample['label']}") | |
| except Exception as e: | |
| print(f"β Error loading Food-102: {e}") | |
| # Check Multi-label Food Recognition | |
| print("\n2. MULTI-LABEL FOOD RECOGNITION DATASET") | |
| print("-" * 60) | |
| try: | |
| multi_dir = os.path.join(base_dir, 'multi-label-food-recognition', 'data') | |
| multi_files = [] | |
| if os.path.exists(multi_dir): | |
| for f in os.listdir(multi_dir): | |
| if f.endswith('.parquet'): | |
| multi_files.append(os.path.join(multi_dir, f)) | |
| if multi_files: | |
| # Load just one file | |
| ds = load_dataset('parquet', data_files=multi_files[:1]) | |
| print(f"β Successfully loaded Multi-label dataset") | |
| print(f" Columns: {ds['train'].column_names}") | |
| print(f" Num samples (in first file): {len(ds['train'])}") | |
| print(f" Total parquet files: {len(multi_files)}") | |
| # Show first sample | |
| sample = ds['train'][0] | |
| print(f" Sample keys: {list(sample.keys())}") | |
| if 'labels' in sample: | |
| print(f" Labels (multi): {sample['labels']}") | |
| if 'label_names' in sample: | |
| print(f" Label names: {sample['label_names']}") | |
| except Exception as e: | |
| print(f"β Error loading Multi-label: {e}") | |
| # Check fooddetection directory | |
| print("\n3. FOODDETECTION DATASET") | |
| print("-" * 60) | |
| try: | |
| fooddet_dir = os.path.join(base_dir, 'fooddetection') | |
| if os.path.exists(fooddet_dir): | |
| items = os.listdir(fooddet_dir) | |
| print(f" Directory contents: {items}") | |
| else: | |
| print(" Directory not found") | |
| except Exception as e: | |
| print(f"β Error checking fooddetection: {e}") | |
| print("\n" + "=" * 60) | |
| print("SUMMARY:") | |
| print("=" * 60) | |
| print("These datasets can be used to:") | |
| print("1. Fine-tune the EfficientNet model on Food-102 classes") | |
| print("2. Train multi-label detection (multiple foods in one image)") | |
| print("3. Improve accuracy on specific food categories") | |
| print("\nNote: Fine-tuning requires GPU and several hours of training") | |
| print("=" * 60) | |