HuggingFace镜像/cspresnext50.ra_in1k
模型介绍文件和版本分析
下载使用量0

cspresnext50.ra_in1k 模型卡片

一个 CSP-ResNeXt(Cross-Stage-Partial,跨阶段部分连接)图像分类模型。在 timm 中基于下述训练方案模板在 ImageNet-1k 数据集上进行训练。

方案详情:

  • RandAugment RA 数据增强方案。灵感来源于并发展自 EfficientNet RandAugment 方案。在论文 ResNet Strikes Back 中被称为 B 方案。
  • RMSProp(TF 1.0 行为模式)优化器,EMA 权重平均
  • 带预热的 Step(指数衰减带阶梯式下降)学习率调度

模型详情

  • 模型类型: 图像分类 / 特征主干网络
  • 模型统计:
    • 参数数量(百万):20.6
    • GMACs:4.0
    • 激活值数量(百万):15.9
    • 图像尺寸:256 x 256
  • 相关论文:
    • CSPNet: A New Backbone that can Enhance Learning Capability of CNN: https://arxiv.org/abs/1911.11929
    • Aggregated Residual Transformations for Deep Neural Networks: https://arxiv.org/abs/1611.05431
    • ResNet strikes back: An improved training procedure in timm: https://arxiv.org/abs/2110.00476
  • 原始出处: https://github.com/huggingface/pytorch-image-models

模型用途

图像分类


# from urllib.request import urlopen
from PIL import Image
import timm
import argparse
import torch
from openmind import is_torch_npu_available


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="Path to the model file",
        default=None,
    )
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    args = parse_args()
    if is_torch_npu_available():
        device = "npu:0"
    else:
        device = "cpu"
    model_path = args.model_name_or_path
    img = model_path + "/Img/beignets-task-guide.png"
    img = Image.open(img)

    model_name = 'cspresnext50.ra_in1k'
    checkpoint_path = model_path + '/pytorch_model.bin'
    model = timm.create_model(model_name, pretrained=False, checkpoint_path=checkpoint_path).to(device)
    model = model.eval()

    # get model specific transforms (normalization, resize)
    data_config = timm.data.resolve_model_data_config(model)
    transforms = timm.data.create_transform(**data_config, is_training=False)

    output = model(transforms(img).unsqueeze(0).to(device))  # unsqueeze single image into batch of 1

    top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
    print("top5_probabilities", top5_probabilities)
    # top5_probabilities tensor([[32.3464,  7.3088,  2.4411,  1.6829,  1.6539]], device='npu:0',
    #    grad_fn=<TopkBackward0>)
    print("top5_class_indices", top5_class_indices)
    # top5_class_indices tensor([[969, 960, 967, 923, 968]], device='npu:0')

模型对比

在 timm 的 model results 中探索此模型的数据集和运行时指标。

引用

@article{Wang2019CSPNetAN,
  title={CSPNet: A New Backbone that can Enhance Learning Capability of CNN},
  author={Chien-Yao Wang and Hong-Yuan Mark Liao and I-Hau Yeh and Yueh-Hua Wu and Ping-Yang Chen and Jun-Wei Hsieh},
  journal={2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW)},
  year={2019},
  pages={1571-1580}
}
@article{Xie2016,
  title={Aggregated Residual Transformations for Deep Neural Networks},
  author={Saining Xie and Ross Girshick and Piotr Dollár and Zhuowen Tu and Kaiming He},
  journal={arXiv preprint arXiv:1611.05431},
  year={2016}
}
@inproceedings{wightman2021resnet,
  title={ResNet strikes back: An improved training procedure in timm},
  author={Wightman, Ross and Touvron, Hugo and Jegou, Herve},
  booktitle={NeurIPS 2021 Workshop on ImageNet: Past, Present, and Future}
}
@misc{rw2019timm,
  author = {Ross Wightman},
  title = {PyTorch Image Models},
  year = {2019},
  publisher = {GitHub},
  journal = {GitHub repository},
  doi = {10.5281/zenodo.4414861},
  howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
}