公司动态
从特征提取到图像嵌入:convnext_tiny.in12k_ft_in1k 多场景应用指南
从特征提取到图像嵌入convnext_tiny.in12k_ft_in1k 多场景应用指南【免费下载链接】convnext_tiny.in12k_ft_in1k项目地址: https://ai.gitcode.com/hf_mirrors/timm/convnext_tiny.in12k_ft_in1kconvnext_tiny.in12k_ft_in1k 是一款基于 ConvNeXt 架构的图像分类模型由 Ross Wightman 在 timm 库中开发。该模型先在 ImageNet-12k包含 11821 个类别的 ImageNet-22k 子集上进行预训练然后在 ImageNet-1k 上进行微调能高效完成图像分类、特征提取和图像嵌入等多种计算机视觉任务。 模型核心优势轻量级高效设计作为一款轻量级模型convnext_tiny.in12k_ft_in1k 仅包含28.6M 参数GMACs 为 4.5Activations 达 13.4M在保证性能的同时大幅降低了计算资源需求。其训练图像尺寸为 224x224测试图像尺寸为 288x288能在不同设备上灵活部署。卓越性能表现在 ImageNet-1k 数据集上该模型的 top1 准确率达到84.186%top5 准确率为97.124%每秒可处理 2433.7 个样本batch_size256在同类轻量级模型中表现出色完美平衡了精度与速度。 快速上手指南环境准备首先确保已安装 timm 库和 PyTorch。若需使用该模型可通过以下命令克隆仓库git clone https://gitcode.com/hf_mirrors/timm/convnext_tiny.in12k_ft_in1k图像分类基础实现使用 convnext_tiny.in12k_ft_in1k 进行图像分类仅需几行代码from urllib.request import urlopen from PIL import Image import timm # 加载图像 img Image.open(urlopen(https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png)) # 创建并加载预训练模型 model timm.create_model(convnext_tiny.in12k_ft_in1k, pretrainedTrue) model model.eval() # 获取模型特定的变换归一化、 resize data_config timm.data.resolve_model_data_config(model) transforms timm.data.create_transform(**data_config, is_trainingFalse) # 进行推理 output model(transforms(img).unsqueeze(0)) top5_probabilities, top5_class_indices torch.topk(output.softmax(dim1) * 100, k5) 多场景应用实践特征图提取深入解析图像特征通过设置features_onlyTrue可提取图像在不同网络层的特征图用于后续的目标检测、图像分割等任务model timm.create_model( convnext_tiny.in12k_ft_in1k, pretrainedTrue, features_onlyTrue, ) output model(transforms(img).unsqueeze(0)) # 输出包含多个特征图 # 特征图形状示例 # torch.Size([1, 96, 56, 56]) # torch.Size([1, 192, 28, 28]) # torch.Size([1, 384, 14, 14]) # torch.Size([1, 768, 7, 7])图像嵌入构建图像向量表示将图像转换为固定维度的嵌入向量可用于图像检索、相似度计算等场景。通过设置num_classes0或使用forward_features方法实现# 方法一移除分类器 model timm.create_model( convnext_tiny.in12k_ft_in1k, pretrainedTrue, num_classes0, # 移除分类器 nn.Linear ) output model(transforms(img).unsqueeze(0)) # 输出形状 (batch_size, num_features) # 方法二使用 forward_features output model.forward_features(transforms(img).unsqueeze(0)) # 未池化特征 output model.forward_head(output, pre_logitsTrue) # 池化后特征 (1, num_features) 模型配置详解convnext_tiny.in12k_ft_in1k 的配置信息存储在 config.json 中关键参数如下输入尺寸训练时为 [3, 224, 224]测试时为 [3, 288, 288]归一化参数mean [0.485, 0.456, 0.406]std [0.229, 0.224, 0.225]池化大小[7, 7]分类器head.fc这些配置确保了模型在不同输入图像上的稳定性能用户可根据实际需求调整输入尺寸和预处理方式。 相关资源与引用技术文档模型详细信息README.md配置参数说明config.json学术引用如果在研究中使用了 convnext_tiny.in12k_ft_in1k请引用以下论文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}} } article{liu2022convnet, author {Zhuang Liu and Hanzi Mao and Chao-Yuan Wu and Christoph Feichtenhofer and Trevor Darrell and Saining Xie}, title {A ConvNet for the 2020s}, journal {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}, year {2022}, }convnext_tiny.in12k_ft_in1k 凭借其轻量级设计和优异性能成为计算机视觉任务的理想选择。无论是图像分类、特征提取还是图像嵌入都能为用户提供高效可靠的解决方案。赶快尝试使用开启你的计算机视觉之旅吧 【免费下载链接】convnext_tiny.in12k_ft_in1k项目地址: https://ai.gitcode.com/hf_mirrors/timm/convnext_tiny.in12k_ft_in1k创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考