File size: 3,757 Bytes
97fd5d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
 # 🧠 Food-Image-Classification-AI-Model

A Food image classification model fine-tuned on the Food-101 dataset using the powerful facebook/deit-base-patch16-224 architecture. This model classifies images into one of 101 popular food categories such as pizza, ramen, pad thai, sushi, and more.


---


## ✨ Model Highlights

- πŸ“Œ Base Model: facebook/deit-base-patch16-224
- πŸ“š Datasets: 	Food-101 Data
- 🌿 Classes: 101 food categories (e.g., pizza, ramen, steak, etc.)
- πŸ”§ Framework: Hugging Face Transformers + PyTorch

---

## 🧠 Intended Uses

- βœ… Food image classification in apps/web
- βœ… Educational visual datasets
- βœ… Food blog/media categorization
- βœ… Restaurant ordering support systems

---

## 🚫 Limitations

- ❌ May not perform well on poor-quality or mixed-food images
- ❌  Not optimized for detecting multiple food items per image


---

## πŸ‹οΈβ€β™‚οΈ Training Details

| Attribute          | Value                            |
|--------------------|----------------------------------|
| Base Model         | facebook/deit-base-patch16-224   |
| Dataset            | Food-101-Dataset                 |
| Task Type          | Image Classification             |
| Epochs             | 3                                |
| Batch Size         | 16                               |
| Optimizer          | AdamW                            |
| Loss Function      | CrossEntropyLoss                 |
| Framework          | PyTorch + Transformers           |
| Hardware           | CUDA-enabled GPU                 |

---

## πŸ“Š Evaluation Metrics


| Metric                                          | Score |
| ----------------------------------------------- | ----- |
| Accuracy                                        | 0.97  |
| F1-Score                                        | 0.98  |
| Precision                                       | 0.99  |
| Recall                                          | 0.97  |


---

---
πŸš€ Usage
```python
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch
from torchvision.transforms import Compose, Resize, ToTensor, Normalize

# Load model and processor
model_name = "AventIQ-AI/Food-Classification-AI-Model"

model = AutoModelForImageClassification.from_pretrained("your-model-path")
processor = AutoImageProcessor.from_pretrained("your-model-path")

def predict(image_path):
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    model.to(device)

    image = Image.open(image_path).convert("RGB")
    transform = Compose([
        Resize((224, 224)),
        ToTensor(),
        Normalize(mean=processor.image_mean, std=processor.image_std)
    ])
    pixel_values = transform(image).unsqueeze(0).to(device)

    with torch.no_grad():
        outputs = model(pixel_values=pixel_values)
        logits = outputs.logits
        predicted_idx = logits.argmax(-1).item()
        predicted_label = model.config.id2label[predicted_idx]
    
    return predicted_label

# Example usage:
print(predict("Foodexample.jpg"))

```
---

- 🧩 Quantization
- Post-training static quantization applied using PyTorch to reduce model size and accelerate inference on edge devices.

----

πŸ—‚ Repository Structure
```
.
beans-vit-finetuned/
β”œβ”€β”€ config.json               βœ… Model architecture & config
β”œβ”€β”€ pytorch_model.bin         βœ… Model weights
β”œβ”€β”€ preprocessor_config.json  βœ… Image processor config
β”œβ”€β”€ training_args.bin         βœ… Training metadata
β”œβ”€β”€ README.md                 βœ… Model card

```
---
🀝 Contributing

Open to improvements and feedback! Feel free to submit a pull request or open an issue if you find any bugs or want to enhance the model.