Update README.md
Browse files
README.md
CHANGED
@@ -8,4 +8,49 @@ pipeline_tag: image-classification
|
|
8 |
tags:
|
9 |
- aircraft
|
10 |
- airplane
|
11 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
tags:
|
9 |
- aircraft
|
10 |
- airplane
|
11 |
+
---
|
12 |
+
# Aircraft Classifier
|
13 |
+
|
14 |
+
This repository contains a pre-trained PyTorch model for classifying aircraft types based on images. The model file `aircraft_classifier.pth` can be downloaded and used to classify images of various aircraft models.
|
15 |
+
|
16 |
+
## Model Overview
|
17 |
+
|
18 |
+
The `aircraft_classifier.pth` file is a PyTorch model trained on a dataset of aircraft images. It achieves a test accuracy of **75.26%** on the FGVC Aircraft test dataset, making it a reliable choice for identifying aircraft types. The model is designed to be lightweight and efficient for real-time applications.
|
19 |
+
|
20 |
+
## Requirements
|
21 |
+
|
22 |
+
- **Python** 3.7 or higher
|
23 |
+
- **PyTorch** 1.8 or higher
|
24 |
+
- **torchvision** (for loading and preprocessing images)
|
25 |
+
|
26 |
+
## Usage
|
27 |
+
|
28 |
+
1. Clone this repository and install dependencies.
|
29 |
+
```bash
|
30 |
+
git clone <repository-url>
|
31 |
+
cd <repository-folder>
|
32 |
+
pip install torch torchvision
|
33 |
+
```
|
34 |
+
2. Load and use the model in your Python script:
|
35 |
+
```python
|
36 |
+
import torch
|
37 |
+
from torchvision import transforms
|
38 |
+
from PIL import Image
|
39 |
+
|
40 |
+
# Load the model
|
41 |
+
model = torch.load('aircraft_classifier.pth')
|
42 |
+
model.eval() # Set to evaluation mode
|
43 |
+
|
44 |
+
# Load and preprocess the image
|
45 |
+
transform = transforms.Compose([
|
46 |
+
transforms.Resize((224, 224)),
|
47 |
+
transforms.ToTensor(),
|
48 |
+
])
|
49 |
+
img = Image.open('path_to_image.jpg')
|
50 |
+
img = transform(img).view(1, 3, 224, 224) # Reshape to (1, 3, 224, 224) for batch processing
|
51 |
+
|
52 |
+
# Predict
|
53 |
+
with torch.no_grad():
|
54 |
+
output = model(img)
|
55 |
+
_, predicted = torch.max(output, 1)
|
56 |
+
print("Predicted Aircraft Type:", predicted.item())
|