|
--- |
|
license: mit |
|
base_model: |
|
- timm/tf_efficientnet_b0.in1k |
|
pipeline_tag: image-classification |
|
tags: |
|
- pizza |
|
- steak |
|
- sushi |
|
--- |
|
# Food Classifier |
|
|
|
This repository contains a pre-trained PyTorch model for classifying food based on images. The model file `food_model.pth` can be downloaded and used to classify images of pizza, steak or sushi. |
|
|
|
## Model Overview |
|
|
|
The `food_model.pth` file is a PyTorch model trained on a dataset of food images. It achieves a test accuracy of **84.56%**, making it a reliable choice for identifying pizza, steak, and sushi. The model is designed to be lightweight and efficient for real-time applications. |
|
|
|
## Requirements |
|
|
|
- **Python** 3.7 or higher |
|
- **PyTorch** 1.8 or higher |
|
- **torchvision** (for loading and preprocessing images) |
|
|
|
## Usage |
|
|
|
1. Clone this repository and install dependencies. |
|
```bash |
|
git clone <repository-url> |
|
cd <repository-folder> |
|
pip install torch torchvision |
|
``` |
|
2. Load and use the model in your Python script: |
|
```python |
|
import torch |
|
from torchvision import transforms |
|
from PIL import Image |
|
|
|
# Load the model |
|
model = torch.load('aircraft_classifier.pth') |
|
model.eval() # Set to evaluation mode |
|
|
|
# Load and preprocess the image |
|
transform = transforms.Compose([ |
|
transforms.Resize((224, 224)), |
|
transforms.ToTensor(), |
|
]) |
|
img = Image.open('path_to_image.jpg') |
|
img = transform(img).view(1, 3, 224, 224) # Reshape to (1, 3, 224, 224) for batch processing |
|
|
|
# Predict |
|
with torch.no_grad(): |
|
output = model(img) |
|
_, predicted = torch.max(output, 1) |
|
print("Predicted Food Type:", predicted.item()) |