如何用RegNetY-320.SWAG-FT-In1k实现高效图像分类?5分钟上手教程
如何用RegNetY-320.SWAG-FT-In1k实现高效图像分类5分钟上手教程【免费下载链接】regnety_320.swag_ft_in1k项目地址: https://ai.gitcode.com/hf_mirrors/timm/regnety_320.swag_ft_in1kRegNetY-320.SWAG-FT-In1k是一款基于RegNetY架构的高效图像分类模型通过SWAG弱监督学习在约36亿Instagram图像及相关标签上预训练并在ImageNet-1k数据集上进行微调非常适合新手和普通用户快速实现高精度图像分类任务。 为什么选择RegNetY-320.SWAG-FT-In1k这款模型在图像分类领域表现出色具有以下核心优势高精度性能在ImageNet-1k数据集上达到86.84%的top1准确率和98.364%的top5准确率参数数量145.05M计算量95.0 GMACs平衡了性能与效率。丰富功能支持不仅支持基础图像分类还能进行特征图提取和图像嵌入生成满足多样化视觉任务需求。易于使用基于PyTorch框架通过timm库可快速调用无需复杂配置5分钟即可完成从安装到推理的全流程。⚙️ 环境准备与安装一键安装必要依赖首先确保已安装Python环境然后通过pip安装timm库和PyTorchpip install timm torch torchvision克隆项目仓库git clone https://gitcode.com/hf_mirrors/timm/regnety_320.swag_ft_in1k cd regnety_320.swag_ft_in1k 快速上手图像分类实战步骤1导入必要库from urllib.request import urlopen from PIL import Image import timm import torch步骤2加载模型与图像# 加载预训练模型 model timm.create_model(regnety_320.swag_ft_in1k, pretrainedTrue) model model.eval() # 加载示例图像 img Image.open(urlopen( https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png ))步骤3数据预处理# 获取模型特定的预处理变换归一化、 resize等 data_config timm.data.resolve_model_data_config(model) transforms timm.data.create_transform(**data_config, is_trainingFalse) # 对图像进行预处理并添加批次维度 input_tensor transforms(img).unsqueeze(0)步骤4执行推理并获取结果# 模型推理 output model(input_tensor) # 获取top5预测结果 top5_probabilities, top5_class_indices torch.topk(output.softmax(dim1) * 100, k5) # 打印结果 print(Top 5预测类别及概率) for prob, idx in zip(top5_probabilities[0], top5_class_indices[0]): print(f类别 {idx}: {prob:.2f}%) 模型进阶应用特征图提取RegNetY-320.SWAG-FT-In1k可用于提取图像的多层特征图用于后续视觉任务model timm.create_model( regnety_320.swag_ft_in1k, pretrainedTrue, features_onlyTrue, ) model model.eval() output model(transforms(img).unsqueeze(0)) for o in output: print(f特征图形状: {o.shape})图像嵌入生成生成图像的特征嵌入可用于图像检索、相似度计算等任务model timm.create_model( regnety_320.swag_ft_in1k, pretrainedTrue, num_classes0, # 移除分类器 ) model model.eval() output model(transforms(img).unsqueeze(0)) # 输出形状: (1, 3712) print(f图像嵌入维度: {output.shape[1]}) 模型配置与参数模型的详细配置信息可在config.json中查看主要参数包括输入尺寸3×384×384通道×高度×宽度归一化参数mean[0.485, 0.456, 0.406]std[0.229, 0.224, 0.225]类别数量1000对应ImageNet-1k数据集类别特征维度3712图像嵌入维度 模型性能对比在timm库的模型结果中RegNetY-320.SWAG-FT-In1k与其他RegNet系列模型相比在精度和效率上表现优异模型图像尺寸top1准确率top5准确率参数数量(M)GMACsregnety_320.swag_ft_in1k38486.8498.364145.0595.0regnety_160.swag_ft_in1k38486.02498.0583.5946.87regnety_320.swag_lc_in1k22484.5697.446145.0532.34 许可证与引用本模型使用CC-BY-NC-4.0许可证仅供非商业用途。如果在研究中使用该模型请引用以下论文inproceedings{singh2022revisiting, title{{Revisiting Weakly Supervised Pre-Training of Visual Perception Models}}, author{Singh, Mannat and Gustafson, Laura and Adcock, Aaron and Reis, Vinicius de Freitas and Gedik, Bugra and Kosaraju, Raj Prateek and Mahajan, Dhruv and Girshick, Ross and Doll{a}r, Piotr and van der Maaten, Laurens}, booktitle{CVPR}, year{2022} }InProceedings{Radosavovic2020, title {Designing Network Design Spaces}, author {Ilija Radosavovic and Raj Prateek Kosaraju and Ross Girshick and Kaiming He and Piotr Doll{a}r}, booktitle {CVPR}, year {2020} }通过以上步骤你已经掌握了RegNetY-320.SWAG-FT-In1k的基本使用方法。无论是图像分类、特征提取还是嵌入生成这款模型都能为你提供高效准确的视觉任务解决方案。现在就动手尝试开启你的图像分类之旅吧【免费下载链接】regnety_320.swag_ft_in1k项目地址: https://ai.gitcode.com/hf_mirrors/timm/regnety_320.swag_ft_in1k创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关新闻

最新新闻

日新闻

周新闻

月新闻