Shivam Sharma
commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,10 +1,53 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
datasets:
|
| 4 |
-
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- vision
|
| 6 |
+
- image-classification
|
| 7 |
+
- resnet
|
| 8 |
+
- onnx
|
| 9 |
+
- cifar10
|
| 10 |
+
framework:
|
| 11 |
+
- pytorch
|
| 12 |
+
- onnx
|
| 13 |
datasets:
|
| 14 |
+
- cifar10
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# ResNet-18 trained on CIFAR-10 (ONNX)
|
| 18 |
+
|
| 19 |
+
This is a ResNet-18 model trained on the CIFAR-10 dataset, exported to the **ONNX** format for easy deployment across different platforms.
|
| 20 |
+
|
| 21 |
+
## Model Details
|
| 22 |
+
- **Architecture:** ResNet-18 (modified for CIFAR-10 input size)
|
| 23 |
+
- **Framework:** PyTorch → ONNX export
|
| 24 |
+
- **Input size:** `3 × 224 × 224` RGB images
|
| 25 |
+
- **Number of classes:** 10 (airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck)
|
| 26 |
+
|
| 27 |
+
## Intended Use
|
| 28 |
+
This model is designed for educational purposes, demos, and quick prototyping of ONNX-based image classification workflows.
|
| 29 |
+
|
| 30 |
+
## How to Use
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
import onnxruntime as ort
|
| 34 |
+
import numpy as np
|
| 35 |
+
from PIL import Image
|
| 36 |
+
|
| 37 |
+
# Load model
|
| 38 |
+
session = ort.InferenceSession("resnet18_cifar10.onnx")
|
| 39 |
+
|
| 40 |
+
# Preprocess image
|
| 41 |
+
def preprocess(img_path):
|
| 42 |
+
img = Image.open(img_path).convert("RGB").resize((32, 32))
|
| 43 |
+
img_data = np.array(img).astype(np.float32) / 255.0
|
| 44 |
+
img_data = np.transpose(img_data, (2, 0, 1)) # CHW format
|
| 45 |
+
img_data = np.expand_dims(img_data, axis=0) # Batch dimension
|
| 46 |
+
return img_data
|
| 47 |
+
|
| 48 |
+
input_data = preprocess("example.jpg")
|
| 49 |
+
|
| 50 |
+
# Run inference
|
| 51 |
+
outputs = session.run(None, {"input": input_data})
|
| 52 |
+
pred_class = np.argmax(outputs[0])
|
| 53 |
+
print("Predicted class:", pred_class)
|