🚀 ResNet-34模型
该模型在ImageNette数据集上进行了预训练,ResNet架构在 这篇论文 中被提出,可用于图像分类任务。
🚀 快速开始
本项目提供了一个基于ResNet-34架构的预训练模型,可用于图像分类任务。它在ImageNette数据集上进行了预训练,你可以根据自己的需求进行微调或直接使用。
✨ 主要特性
- 预训练模型:在ImageNette数据集上进行了预训练,可快速应用于图像分类任务。
- 多种安装方式:支持通过pypi、conda以及从源代码安装。
- 易于使用:提供了详细的使用示例,方便用户快速上手。
📦 安装指南
前提条件
安装Holocron需要Python 3.6(或更高版本)以及 pip/conda。
最新稳定版本
你可以使用 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/resnet34").eval()
img = Image.open(path_to_an_image).convert("RGB")
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)
with torch.inference_mode():
output = model(input_tensor)
probs = output.squeeze(0).softmax(dim=0)
📚 详细文档
模型描述
作者的核心思想是通过添加跳跃连接(skip connection)来帮助梯度在众多层中传播。
📄 许可证
本项目采用Apache-2.0许可证。
📚 引用
原论文
@article{DBLP:journals/corr/HeZRS15,
author = {Kaiming He and
Xiangyu Zhang and
Shaoqing Ren and
Jian Sun},
title = {Deep Residual Learning for Image Recognition},
journal = {CoRR},
volume = {abs/1512.03385},
year = {2015},
url = {http://arxiv.org/abs/1512.03385},
eprinttype = {arXiv},
eprint = {1512.03385},
timestamp = {Wed, 17 Apr 2019 17:23:45 +0200},
biburl = {https://dblp.org/rec/journals/corr/HeZRS15.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}
}