模型:

frgfm/rexnet2_0x

英文

ReXNet-2.0x模型

在 ImageNette 上预训练。ReXNet架构是在 this paper 中引入的。

模型描述

作者的核心思想是在残差块中添加一个定制的Squeeze-Excitation层,以防止通道冗余。

安装

先决条件

需要Python 3.6(或更高版本)和 pip / conda 来安装Holocron。

最新稳定版本

您可以使用 pypi 安装软件包的最新稳定版本,如下所示:

pip install pylocron

或者使用 conda :

conda install -c frgfm pylocron

开发者模式

或者,如果您希望使用项目的最新功能,这些功能尚未发布,您可以从源代码安装软件包(先安装 Git ):

git clone https://github.com/frgfm/Holocron.git
pip install -e Holocron/.

使用说明

from PIL import Image
from torchvision.transforms import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize
from torchvision.transforms.functional import InterpolationMode
from holocron.models import model_from_hf_hub

model = model_from_hf_hub("frgfm/rexnet2_0x").eval()

img = Image.open(path_to_an_image).convert("RGB")

# Preprocessing
config = model.default_cfg
transform = Compose([
    Resize(config['input_shape'][1:], interpolation=InterpolationMode.BILINEAR),
    PILToTensor(),
    ConvertImageDtype(torch.float32),
    Normalize(config['mean'], config['std'])
])

input_tensor = transform(img).unsqueeze(0)

# Inference
with torch.inference_mode():
    output = model(input_tensor)
probs = output.squeeze(0).softmax(dim=0)

引用

原始论文

@article{DBLP:journals/corr/abs-2007-00992,
  author    = {Dongyoon Han and
               Sangdoo Yun and
               Byeongho Heo and
               Young Joon Yoo},
  title     = {ReXNet: Diminishing Representational Bottleneck on Convolutional Neural
               Network},
  journal   = {CoRR},
  volume    = {abs/2007.00992},
  year      = {2020},
  url       = {https://arxiv.org/abs/2007.00992},
  eprinttype = {arXiv},
  eprint    = {2007.00992},
  timestamp = {Mon, 06 Jul 2020 15:26:01 +0200},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2007-00992.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

此实现的来源

@software{Fernandez_Holocron_2020,
author = {Fernandez, François-Guillaume},
month = {5},
title = {{Holocron}},
url = {https://github.com/frgfm/Holocron},
year = {2020}
}