File size: 2,683 Bytes
59d7aa4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
tags:
  - image-classification
  - computer-vision
  - vegetables
  - pytorch
  - food
datasets:
  - Custom
metrics:
  - accuracy
  - confusion_matrix
model-index:
  - name: VeggieNet
    results:
      - task:
          type: image-classification
          name: Image Classification
        dataset:
          name: Custom Vegetable Dataset
          type: image
        metrics:
          - type: accuracy
            value: 91.63%
          - type: confusion_matrix
            value: included
---

# πŸ₯• VeggieNet: Vegetable Image Classifier

**VeggieNet** is a deep learning model trained in PyTorch for classifying vegetable images into categories like tomato, carrot, potato, etc. It uses a fully connected neural network with regularization (BatchNorm and Dropout) to prevent overfitting and improve generalization.

## 🧠 Model Architecture

The network takes 128x128 RGB images and passes them through the following layers:

```python
nn.Sequential(
    nn.Flatten(),
    nn.Linear(3 * 128 * 128, 512),
    nn.BatchNorm1d(512),
    nn.ReLU(),
    nn.Dropout(0.3),
    nn.Linear(512, 256),
    nn.BatchNorm1d(256),
    nn.ReLU(),
    nn.Dropout(0.3),
    nn.Linear(256, 128),
    nn.BatchNorm1d(128),
    nn.ReLU(),
    nn.Dropout(0.3),
    nn.Linear(128, num_classes)
)
```

- **Loss Function**: `CrossEntropyLoss`
- **Optimizer**: `Adam`
- **Input Size**: `3x128x128`
- **Output**: `num_classes` (one per vegetable category)

## πŸ“‚ Dataset

This model is trained on a custom dataset from kaggle of vegetable images organized into:

```
vegetables_dataset/
β”œβ”€β”€ train/
β”œβ”€β”€ val/
└── test/
```

Each subfolder represents a vegetable class (e.g., `carrot/`, `tomato/`, etc.). To download [Click Here](https://www.kaggle.com/datasets/misrakahmed/vegetable-image-dataset?select=Vegetable+Images)

## πŸ“ˆ Training & Evaluation

- Trained for **10 epochs**
- Batch size: 16
- Includes validation + test evaluation
- Final accuracy on test set: **~91.63%**
- Confusion matrix is included in the evaluation

## βœ… Intended Use

- Educational projects
- Computer vision experiments
- Simple food classification tasks

## 🚫 Limitations

- Not robust to background noise or very similar vegetables
- May underperform on unseen real-world data if distribution differs

## πŸ’‘ Future Improvements

- Replace FC layers with a CNN for better spatial feature learning
- Use transfer learning (e.g., ResNet18)
- Increase dataset diversity and quantity

## πŸ“œ License

This model is available under the **Apache-2.0 License**.

## ✍️ Author

- Created by: *Arun  Arunisto*
- GitHub: [arun-arunisto](https://github.com/arun-arunisto)