File size: 1,399 Bytes
cbd31fe a415b7d cbd31fe a415b7d b4294ef a415b7d | 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 | ---
language: en
license: mit
tags:
- vision
- image-classification
- resnet
- onnx
- cifar10
framework:
- pytorch
- onnx
datasets:
- cifar10
---
# ResNet-18 trained on CIFAR-10 (ONNX)
This is a ResNet-18 model trained on the CIFAR-10 dataset, exported to the **ONNX** format for easy deployment across different platforms.
## Model Details
- **Architecture:** ResNet-18 (modified for CIFAR-10 input size)
- **Framework:** PyTorch → ONNX export
- **Input size:** `3 × 224 × 224` RGB images
- **Number of classes:** 10 (airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck)
## Intended Use
This model is designed for educational purposes, demos, and quick prototyping of ONNX-based image classification workflows.
## How to Use
```python
import onnxruntime as ort
import numpy as np
from PIL import Image
# Load model
session = ort.InferenceSession("resnet18_cifar10.onnx")
# Preprocess image
def preprocess(img_path):
img = Image.open(img_path).convert("RGB").resize((224, 224))
img_data = np.array(img).astype(np.float32) / 255.0
img_data = np.transpose(img_data, (2, 0, 1)) # CHW format
img_data = np.expand_dims(img_data, axis=0) # Batch dimension
return img_data
input_data = preprocess("example.jpg")
# Run inference
outputs = session.run(None, {"input": input_data})
pred_class = np.argmax(outputs[0])
print("Predicted class:", pred_class)
|