You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

chuyi — CNN 图像分类模型(洛天依 & 初音未来)

自定义 CNN 二分类模型,用于区分 lty(洛天依 / Luo Tianyi)miku(初音未来 / Hatsune Miku) 两类图片。模型以 ONNX 格式发布,仅需 onnxruntime 即可推理,无需 PyTorch。

模型信息

项目 内容
文件名 chuyi.onnx
架构 自定义 CNN(~11M 参数,width_mult=1.0
输入 input[N, 3, 224, 224] float32,动态 batch
输出 logits[N, 2]
类别 0 = lty(洛天依),1 = miku(初音未来)
ONNX opset 14
文件大小 ~42.7 MB

训练配置

  • 云端AutoDL平台 (RTX 3060 12G,torch 2.5.1+cu124 + 本地RTX3080混合精度微调)

推理示例

import numpy as np
import onnxruntime as ort
from PIL import Image

MEAN = np.array([0.485, 0.456, 0.406], dtype=np.float32)
STD = np.array([0.229, 0.224, 0.225], dtype=np.float32)
IMG_SIZE = 224
CLASS_NAMES = ["lty", "miku"]

def preprocess(img: Image.Image) -> np.ndarray:
    img = img.convert("RGB")
    w, h = img.size
    scale = (IMG_SIZE * 1.14) / min(w, h)
    if abs(scale - 1.0) > 1e-6:
        nw, nh = int(round(w * scale)), int(round(h * scale))
        img = img.resize((nw, nh), Image.Resampling.LANCZOS)
    left = (img.size[0] - IMG_SIZE) // 2
    top = (img.size[1] - IMG_SIZE) // 2
    img = img.crop((left, top, left + IMG_SIZE, top + IMG_SIZE))
    x = np.asarray(img, dtype=np.float32) / 255.0
    x = (x - MEAN) / STD
    return np.transpose(x, (2, 0, 1))  # CHW

sess = ort.InferenceSession("chuyi.onnx", providers=["CPUExecutionProvider"])
img = Image.open("test.jpg").convert("RGB")
x = preprocess(img)[None].astype(np.float32)
logits = sess.run(None, {"input": x})[0]
probs = np.exp(logits) / np.exp(logits).sum(axis=1, keepdims=True)
print(dict(zip(CLASS_NAMES, probs[0].round(4))))
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support