ONNX 模型库
返回模型

说明文档

在 CIFAR-10 上训练的 ResNet-18 (ONNX)

这是一个在 CIFAR-10 数据集上训练的 ResNet-18 模型,已导出为 ONNX 格式,便于在不同平台上部署。

模型详情

  • 架构: ResNet-18(针对 CIFAR-10 输入尺寸进行了修改)
  • 框架: PyTorch → ONNX 导出
  • 输入尺寸: 3 × 224 × 224 RGB 图像
  • 类别数量: 10(飞机、汽车、鸟、猫、鹿、狗、青蛙、马、船、卡车)

预期用途

该模型专为教育目的、演示和基于 ONNX 的图像分类工作流程的快速原型设计而设计。

如何使用

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)

NNEngine/RenNEt18_CIFAR10

作者 NNEngine

image-classification
↓ 0 ♥ 1

创建时间: 2025-08-15 20:57:27+00:00

更新时间: 2025-08-15 21:19:28+00:00

在 Hugging Face 上查看

文件 (3)

.gitattributes
README.md
resnet18_cifar10.onnx ONNX