Image L Class
基于 EfficientNet 的图片内容分级模型,支持 L1–L4 四级分类。
Fonte do modelo
- Tipo
- Other
- Tamanho do arquivo
- 15,3–101 MB
- Modelo base
- timm/tf_efficientnetv2_m.in21k_ft_in1k
- Versão
- vRevision 9d5d858
- Atualizado
- 15 de set. de 2026
- Downloads
- 0
- Fonte
- Hugging Face
Descrição da fonte
Image L-Class — 图片内容分级 (L1–L4)
基于 EfficientNet 的图片内容分级模型,支持 L1–L4 四级分类。
分类标准
| 等级 | 说明 | 示例 |
|---|---|---|
| L1 | 轻度性感内容 | 正常身材 + 性感内衣/衣物遮挡下体,姿势正常无性暗示 |
| L2 | 中度性感内容 | 夸张身材 + 衣着性感/较少,姿势有较强性暗示 |
| L3 | 重度性感内容 | 裸露(半裸/全裸),私密部位暴露 |
| L4 | 色情内容 | 明确性行为/性交内容 |
详细分级标准见 数据准备文档
当前版本:v1.0.2(推荐部署)
| 项目 | 值 |
|---|---|
| 版本 | v1.0.2 |
| 文件 | efficientNet/V2M/efficientNet-V2M-best-fp16.onnx(同 v1.0.2 权重) |
| 版本归档 | efficientNet/V2M/efficientNet-V2M-best-fp16-v1.0.2.onnx |
| 架构 | tf_efficientnetv2_m(timm) |
| 输入尺寸 | 384 × 384 |
| 精度 | FP16(ONNX 输入须 float16) |
| 权重 | best checkpoint(best.pt → FP16;训练启用 EMA 但本版导出为 best) |
| 大小 | ~101 MB |
| 训练数据 | ~41K(data_36K_v6,40,928 张:v5 基座 + createporn 扩增) |
| 基座 | 从头训练(50 epoch,resume: null) |
| 定位 | v6 数据集合并重训 |
训练验证集(data_36K_v6_split/val)
| 项目 | 值 |
|---|---|
| Overall Acc | 92.91%(epoch 46,best val acc) |
| 训练 epoch | 50 |
| 最优 epoch | 46 |
与 v1.0.1 使用的
data_20K_v3_split/val、data_24K_v4_split/val为不同划分,Overall 不可直接对比。
数据构成(data_36K_v6)
| 等级 | 样本数 | 来源 |
|---|---|---|
| L1 | 11,233 | v5 11,076 + createporn 157 |
| L2 | 5,468 | v5 4,455 + createporn 1,013 |
| L3 | 10,838 | v5 9,040 + createporn 1,798 |
| L4 | 13,389 | v5 8,718 + createporn 4,671 |
| 合计 | 40,928 | v5(data_33K_v5)+ createporn 导出 |
变更摘要
- 训练数据合并为
data_36K_v6(v5 + createporn,共 40,928 张) - 在 v6 数据上 从头训练 50 epoch(非 v1.0.1 resume)
- 导出
best_fp16.onnx作为线上部署权重
ONNX Runtime 推理(V2M v1.0.2)
import onnxruntime as ort
import numpy as np
from PIL import Image
from torchvision import transforms
MODEL_PATH = "efficientNet/V2M/efficientNet-V2M-best-fp16.onnx"
IMG_SIZE = 384
CLASS_NAMES = ["L1", "L2", "L3", "L4"]
session = ort.InferenceSession(MODEL_PATH, providers=["CPUExecutionProvider"])
input_name = session.get_inputs()[0].name
input_dtype = np.float16 # FP16 模型必须用 float16 喂入
transform = transforms.Compose([
transforms.Resize((IMG_SIZE, IMG_SIZE)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
])
img = Image.open("image.jpg").convert("RGB")
input_tensor = transform(img).unsqueeze(0).numpy().astype(input_dtype)
outputs = session.run(None, {input_name: input_tensor})[0]
pred_id = int(np.argmax(outputs, axis=1)[0])
print(f"预测等级: {CLASS_NAMES[pred_id]}")
推理服务(本地)
cd image_L_class_train/tools/inference_server
python app.py \
--model-path /path/to/efficientNet-V2M-best-fp16.onnx \
--model-format onnx \
--img-size 384 \
--device cpu \
--port 6006
支持 file / files 上传,以及 JSON/form 字段 image_url。
历史版本:v1.0.1
| 项目 | 值 |
|---|---|
| 训练数据 | ~30.6K(含 ~4K qwen-image-edit) |
| 基座 | v1.0.0 权重 --resume 微调(40 epoch) |
| 定位 | L2 / L3 边界档加强 |
| 权重 | EMA(best_ema.pt → FP16) |
| 版本归档 | efficientNet/V2M/efficientNet-V2M-ema-fp16-v1.0.1.onnx |
同集对比(data_20K_v3_split/val,5224 张 @384)
| 等级 | v1.0.0 | v1.0.1 | Δ |
|---|---|---|---|
| Overall | 92.99% | 94.08% | +1.09 |
| L1 Recall | 95.35% | 96.05% | +0.70 |
| L2 Recall | 86.67% | 88.30% | +1.63 |
| L3 Recall | 85.54% | 89.19% | +3.65 |
| L4 Recall | 96.69% | 96.86% | +0.17 |
训练验证集(data_24K_v4_split/val,6113 张)
| 等级 | Precision | Recall | 样本数 |
|---|---|---|---|
| Overall | — | 96.52% | 6113 |
| L1 | 97.51% | 97.55% | 2124 |
| L2 | 92.53% | 93.65% | 913 |
| L3 | 96.45% | 94.88% | 1290 |
| L4 | 97.44% | 97.93% | 1786 |
历史版本:v1.0.0
| 项目 | 值 |
|---|---|
| 训练数据 | ~26K(Civitai 人工复核) |
| 验证集 | data_20K_v3_split/val,5224 张 |
| Overall Acc | 92.99% |
| 等级 | Acc | Precision | Recall | 样本数 |
|---|---|---|---|---|
| L1 | 95.35% | 94.48% | 95.35% | 1848 |
| L2 | 86.67% | 88.32% | 86.67% | 855 |
| L3 | 85.54% | 90.56% | 85.54% | 740 |
| L4 | 96.69% | 94.56% | 96.69% | 1781 |
历史模型:EfficientNet-B0(轻量版)
| 项目 | 值 |
|---|---|
| 文件 | efficientNet/B0/efficientNet-B0.onnx |
| 架构 | EfficientNet-B0 |
| 输入尺寸 | 224 × 224(Resize 256 + CenterCrop 224) |
| 精度 | FP32 |
| 大小 | ~14 MB |
分类精度(B0 基准)
| 等级 | 准确率 |
|---|---|
| Overall | 82.50% (n=1400) |
| L1 | 87.47% |
| L2 | 73.31% |
| L3 | 84.87% |
| L4 | 82.93% |
ONNX Runtime 推理(B0)
import onnxruntime as ort
import numpy as np
from PIL import Image
from torchvision import transforms
session = ort.InferenceSession("efficientNet/B0/efficientNet-B0.onnx")
input_name = session.get_inputs()[0].name
transform = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
])
img = Image.open("image.jpg").convert("RGB")
input_tensor = transform(img).unsqueeze(0).numpy()
outputs = session.run(None, {input_name: input_tensor})[0]
pred_id = np.argmax(outputs, axis=1)[0]
class_names = ["L1", "L2", "L3", "L4"]
print(f"预测等级: {class_names[pred_id]}")
权重文件一览
| 路径 | 大小 | 说明 |
|---|---|---|
efficientNet/V2M/efficientNet-V2M-best-fp16.onnx | ~101 MB | 当前部署:V2M best FP16 @384 v1.0.2 |
efficientNet/V2M/efficientNet-V2M-best-fp16-v1.0.2.onnx | ~101 MB | v1.0.2 版本归档(best) |
efficientNet/V2M/efficientNet-V2M-ema-fp16.onnx | ~101 MB | 遗留指针 → v1.0.1 EMA(勿用于 v1.0.2) |
efficientNet/V2M/efficientNet-V2M-ema-fp16-v1.0.1.onnx | ~101 MB | v1.0.1 版本归档(EMA) |
efficientNet/B0/efficientNet-B0.onnx | ~14 MB | 历史轻量 FP32 @224 |
训练与继续微调
- 训练代码:image_L_class_train
- 框架:timm + PyTorch
- 线上 badcase 对齐 / 继续微调:见仓库内
docs/上线继续训练.md
部署建议
| 场景 | 建议 |
|---|---|
| 生产 | V2M FP16 @384 v1.0.2,ONNX Runtime |
| GPU | FP32 ONNX + CUDA(低延迟) |
| CPU | FP16 ONNX;可设 OMP_NUM_THREADS=32 |
| 轻量 | B0 FP32 @224 |
Fontes
1 fonte
Fontes
1 fonteVerificado 19 de ago.
Artefatos de modelo
5 artefatos
Artefatos de modelo
5 artefatosefficientNet/V2M/efficientNet-V2M-best-fp16-v1.0.2.onnx
onnx · 101 MB · SHA-256 429c5f8ad50a…04ad · Hugging Face
BaixarefficientNet/V2M/efficientNet-V2M-best-fp16.onnx
onnx · 101 MB · SHA-256 429c5f8ad50a…04ad · Hugging Face
BaixarefficientNet/V2M/efficientNet-V2M-ema-fp16-v1.0.1.onnx
onnx · 101 MB · SHA-256 2e8cc1f49d6e…8a13 · Hugging Face
BaixarefficientNet/V2M/efficientNet-V2M-ema-fp16.onnx
onnx · 101 MB · SHA-256 2e8cc1f49d6e…8a13 · Hugging Face
BaixarTrechos de fonte
2 trechos
Trechos de fonte
2 trechos--- language: - en - zh tags: - image-classification - efficientnet-v2-m - onnx - fp16 - content-moderation - image-safety - timm - not-for-all-audiences library_name: onnx pipeline_tag: image-classification base_model: timm/tf_efficientnetv2_m.in21k_ft_in1k base_model_relation: finetune model-index: - name: EfficientNet-V2M best FP16 v1.0.2 results: - task: type: image-classification dataset: name: data_36K_v6_split/val type: custom metrics: - name: Accuracy type: accuracy value: 92.91 source: name: image_L_class_train data_36K_v6 url: https://huggingface.co/jiangchengchengNLP/image_l_class --- # Image L-Class — 图片内容分级 (L1–L4) 基于 EfficientNet 的图片内容分级模型,支持 **L1–L4** 四级分类。 ## 分类标准 | 等级 | 说明 | 示例 | |------|------|------| | **L1** | 轻度性感内容 | 正常身材 + 性感内衣/衣物遮挡下体,姿势正常无性暗示 | | **L2** | 中度性感内容 | 夸张身材 + 衣着性感/较少,姿势有较强性暗示 | | **L3** | 重度性感内容 | 裸露(半裸/全裸),私密部位暴露 | | **L4** | 色情内容 | 明确性行为/性交内容 | 详细分级标准见 [数据准备文档](https://huggingface.co/jiangchengchengNLP/image_l_class_efficient/blob/main/docs/数据准备.md) --- ## 当前版本:**v1.0.2**(推荐部署) | 项目 | 值 | |------|-----| | 版本 | **v1.0.2** | | 文件 | `efficientNet/V2M/efficientNet-V2M-best-fp16.onnx`(同 v1.0.2 权重) | | 版本归档 | `efficientNet/V2M/efficientNet-V2M-best-fp16-v1.0.2.onnx` | | 架构 | `tf_efficientnetv2_m`(timm) | | 输入尺寸 | **384 × 384** | | 精度 | **FP16**(ONNX 输入须 `float16`) | | 权重 | **best** checkpoint(`best.pt` → FP16;训练启用 EMA 但本版导出为 best) | | 大小 | ~101 MB | | 训练数据 | **~41K**(`data_36K_v6`,40,928 张:v5 基座 + createporn 扩增) | | 基座 | **从头训练**(50 epoch,`resume: null`) | | 定位 | **v6 数据集合并重训** | ### 训练验证集(`data_36K_v6_split/val`) | 项目 | 值 | |------|-----| | **Overall Acc** | **92.91%**(epoch 46,best val acc) | | 训练 epoch | 50 | | 最优 epoch | 46 | > 与 v1.0.1 使用的 `data_20K_v3_split/val`、`data_24K_v4_split/val` 为不同划分,Overall **不可直接对比**。 ### 数据构成(`data_36K_v6`) | 等级 | 样本数 | 来源 | |------|--------|------| | L1 | 11,233 | v5 11,076 + createporn 157 | | L2 | 5,468 | v5 4,455 + createporn 1,013 | | L3 | 10,838 | v5 9,040 + createporn 1,798 | | L4 | 13,389 | v5 8,718 + createporn 4,671 | | **合计** | **40,928** | v5(`data_33K_v5`)+ createporn 导出 | ### 变更摘要 - 训练数据合并为 **`data_36K_v6`**(v5 + createporn,共 40,928 张) - 在 v6 数据上 **从头训练** 50 epoch(非 v1.0.1 resume) - 导出 `best_fp16.onnx` 作为线上部署权重 ### ONNX Runtime 推理(V2M v1.0.2) ```python import onnxruntime as ort import numpy as np from PIL import Image from torchvision i...
Source context: 0 downloads · 0 likes · Pipeline image-classification · Library onnx · Repo jiangchengchengNLP/image_l_class
