【计算机视觉】timm包实现EfficientNet

这篇具有很好参考价值的文章主要介绍了【计算机视觉】timm包实现EfficientNet。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、EfficientNet介绍

我们为 EfficientNet 系列模型提供实现和预训练权重。

Paper: EfficientNet: Rethinking Model Scaling for CNNs.

timm 的efficientnet_b5,计算机视觉,计算机视觉,人工智能,timm,EfficientNet,图像分类
此代码和权重已从 timm 实现移植。 这确实意味着某些模型权重经历了从 TF(来自 Google Brain 团队的原始权重)到 PyTorch(timm 库)再回到 TF(timm 的 tfimm 端口)的旅程。

有以下型号可供选择。

二、模型的选择

2.1 MobileNet-V2 models

这些模型对应于 timm 中的 mobilenetv2_... 模型。

mobilenet_v2_{050, 100, 140}。 这些是 MobileNet-V2 模型,通道乘数分别设置为 0.5、1.0 和 1.4。

mobilenet_v2_{110d,120d}。 这些是 MobileNet-V2 模型,(通道、深度)乘数分别设置为 (1.1, 1.2) 和 (1.2, 1.4)。

2.2 Original EfficientNet models

这些模型对应于 timm 中的模型 tf_...

efficientnet_{b0, b1, b2, b3, b4, b5, b6, b7, b8}

2.3 EfficientNet AdvProp 模型,使用对抗性示例进行训练

这些模型对应于 timm 中的 tf_... 模型。

efficientnet_{b0, ..., b8}_ap

2.4 EfficientNet NoisyStudent 模型,通过半监督学习进行训练

这些模型对应于 timm 中的 tf_... 模型。

efficientnet_{b0, ..., b7}_ns
efficientnet_l2_ns_475
efficientnet_l2

2.5 PyTorch versions of the EfficientNet models

这些模型使用对称填充,而不是 TF 中默认的“相同”填充。 它们对应于 timm 中的 effectivenet_... 模型。

pt_efficientnet_{b0, ..., b4}

2.6 EfficientNet-EdgeTPU models, optimized for inference on Google’s Edge TPU hardware

These models correspond to the tf_... models in timm.

efficientnet_es
efficientnet_em
efficientnet_el

2.7 EfficientNet-Lite models, optimized for inference on mobile devices, CPUs and GPUs

These models correspond to the tf_... models in timm.

efficientnet_lite0
efficientnet_lite1
efficientnet_lite2
efficientnet_lite3
efficientnet_lite4

2.8 EfficientNet-V2 models

These models correspond to the tf_... models in timm.

efficientnet_v2_b0
efficientnet_v2_b1
efficientnet_v2_b2
efficientnet_v2_b3
efficientnet_v2_s
efficientnet_v2_m
efficientnet_v2_l

2.9 EfficientNet-V2 models, pretrained on ImageNet-21k, fine-tuned on ImageNet-1k

这些模型对应于 timm 中的 tf_... 模型。

efficientnet_v2_s_in21ft1k
efficientnet_v2_m_in21ft1k
efficientnet_v2_l_in21ft1k
efficientnet_v2_xl_in21ft1k

2.10 EfficientNet-V2 models, pretrained on ImageNet-21k

这些模型对应于 timm 中的 tf_... 模型。

efficientnet_v2_s_in21k
efficientnet_v2_m_in21k
efficientnet_v2_l_in21k
efficientnet_v2_xl_in21k

三、EfficientNetConfig

classEfficientNetConfig(name='', url='', nb_classes=1000, in_channels=3, input_size=(224, 224), stem_size=32, architecture=(), channel_multiplier=1.0, depth_multiplier=1.0, fix_first_last=False, nb_features=1280, drop_rate=0.0, drop_path_rate=0.0, norm_layer='batch_norm', act_layer='swish', padding='symmetric', crop_pct=0.875, interpolation='bicubic', mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), first_conv='conv_stem', classifier='classifier')

EfficientNet 模型的配置类。

Parameters:
name (str) – Name of the model.

url (str) – URL for pretrained weights.

nb_classes (int) – Number of classes for classification head.

in_channels (int) – Number of input image channels.

input_size (Tuple[int, int]) – Input image size (height, width)

stem_size (int) – Number of filters in first convolution.

architecture (Tuple[Tuple[str, ...], ...]) – Tuple of tuple of strings defining the architecture of residual blocks. The outer tuple defines the stages while the inner tuple defines the blocks per stage.

channel_multiplier (float) – Multiplier for channel scaling. One of the three dimensions of EfficientNet scaling.

depth_multiplier (float) – Multiplier for depth scaling. One of the three dimensions of EfficientNet scaling.

fix_first_last (bool) – Fix first and last block depths when multiplier is applied.

nb_features (int) – Number of features before the classifier layer.

drop_rate (float) – Dropout rate.

drop_path_rate (float) – Dropout rate for stochastic depth.

norm_layer (str) – Normalization layer. See norm_layer_factory() for possible values.

act_layer (str) – Activation function. See act_layer_factory() for possible values.

padding (str) – Type of padding to use for convolutional layers. Can be one of “same”, “valid” or “symmetric” (PyTorch-style symmetric padding).

crop_pct (float) – Crop percentage for ImageNet evaluation.

interpolation (str) – Interpolation method for ImageNet evaluation.

mean (Tuple[float, float, float]) – Defines preprocessing function. If x is an image with pixel values in (0, 1), the preprocessing function is (x - mean) / std.

std (Tuple[float, float, float]) – Defines preprpocessing function.

first_conv (str) – Name of first convolutional layer. Used by create_model() to adapt the number in input channels when loading pretrained weights.

classifier (str) – Name of classifier layer. Used by create_model() to adapt the classifier when loading pretrained weights.

四、EfficientNet

classEfficientNet(*args, **kwargs)

支持深度和宽度缩放以及灵活的架构定义的通用 EfficientNet 实现,包括:EfficientNet B0-B7

Parameters:
cfg (EfficientNetConfig) – Configuration class for the model.

**kwargs – Arguments are passed to tf.keras.Model.
call(x, training=False, return_features=False)

前向传递整个模型。

Parameters:
x – Input to model

training (bool) – Training or inference phase?

return_features (bool) – If True, we return not only the model output, but a dictionary with intermediate features.

Returns:
If return_features=True, we return a tuple (y, features), where y is the model output and features is a dictionary with intermediate features.

If return_features=False, we return only y.
propertydummy_inputs: Tensor

返回正确形状的张量以进行推理。

propertyfeature_names: List[str]

功能名称,在调用 return_features=True 时返回。

forward_features(x, training=False, return_features=False)

前向传递模型,不包括分类器层。 如果模型用作下游任务(例如对象检测)的输入,则此函数非常有用。文章来源地址https://www.toymoban.com/news/detail-778202.html

Parameters:
x – Input to model

training (bool) – Training or inference phase?

return_features (bool) – If True, we return not only the model output, but a dictionary with intermediate features.

Returns:
If return_features=True, we return a tuple (y, features), where y is the model output and features is a dictionary with intermediate features.

If return_features=False, we return only y.

到了这里,关于【计算机视觉】timm包实现EfficientNet的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • 计算机视觉:使用dlib实现人脸检测

    计算机视觉:使用dlib实现人脸检测

    Dlib是一个广泛使用的开源库,在计算机视觉和机器学习领域具有重要影响。它是由Davis King在2002年开发,主要用C++语言编写,但也提供了Python接口。Dlib结合了高效的算法和易用性,使其成为学术界和工业界的热门选择。 多样的机器学习算法:Dlib包含丰富的机器学习算法,如

    2024年04月28日
    浏览(14)
  • 主动学习与计算机视觉的结合:实现更智能的视觉系统

    计算机视觉技术在过去的几年里取得了巨大的进步,这主要是由于深度学习技术的蓬勃发展。深度学习技术,特别是卷积神经网络(CNN),已经成为计算机视觉任务的主要工具。然而,尽管深度学习技术在许多任务中表现出色,但它们仍然存在一些问题,其中一个主要问题是数

    2024年02月20日
    浏览(14)
  • 实现ROS机器人的计算机视觉

    计算机视觉是一种通过计算机来处理和理解人类视觉系统所收集到的图像和视频信息的技术。在过去的几十年里,计算机视觉已经成为了一种非常重要的技术,它在很多领域得到了广泛的应用,如自动驾驶、人脸识别、物体检测等。 在过去的几年里,随着机器人技术的发展,

    2024年01月21日
    浏览(11)
  • 计算机视觉:使用opencv实现银行卡号识别

    计算机视觉:使用opencv实现银行卡号识别

    OpenCV是Open Source Computer Vision Library(开源计算机视觉库)的简称,由Intel公司在1999年提出建立,现在由Willow Garage提供运行支持,它是一个高度开源发行的计算机视觉库,可以实现Windows、Linux、Mac等多平台的跨平台操作。opencv是一个用于图像处理、分析、机器视觉方面的开源函

    2024年02月05日
    浏览(15)
  • 【计算机视觉】OpenCV实现单目相机标定

    文章目录 单目相机标定(基于Python OpenCV) 1.上期填坑 2.单目相机标定 2.1 数据采集 2.2 角点提取 2.3 参数求解 2.4 参数评估(重投影误差) 2.5 相机位姿(棋盘位姿)可视化 2.6 同Matlab标定结果比较 在开始本篇博客之前,先填一下上一篇博客【计算机视觉】基于ORB角点+RANSAC算法实现图像

    2023年04月18日
    浏览(12)
  • 基于计算机视觉的机器人视觉:实现对机器人视觉的理解和应用

    作者:禅与计算机程序设计艺术 目前,人类在收集和处理图像数据方面已经取得了非常大的进步。随着技术的不断迭代升级,机器视觉系统也在迅速发展。人工智能领域的研究者们正在将这些技术应用到工业领域,其中就包括机器人的视觉处理方面。由于机器人本身是个动态

    2024年02月08日
    浏览(12)
  • 计算机视觉的花椒外观品质检测及其MATLAB实现

    计算机视觉的花椒外观品质检测及其MATLAB实现

    基于计算机视觉的花椒外观品质检测及其MATLAB实现  作者: 杨飞, 祝诗平, 邱青苗, Yang fei, Zhu Shiping, Qiu Qingmiao 作者单位: 杨飞,邱青苗,Yang fei,Qiu Qingmiao(西南大学工程技术学院,重庆,400716), 祝诗平,Zhu Shiping(西南大学工程技术学院,重庆,400716;重庆大学光电技术及系统

    2024年02月03日
    浏览(7)
  • 【计算机视觉·OpenCV】使用Haar+Cascade实现人脸检测

    【计算机视觉·OpenCV】使用Haar+Cascade实现人脸检测

    人脸检测的目标是找出图像中所有的人脸对应的位置,算法的输出是人脸的外接矩形在图像中的坐标。使用 haar 特征和 cascade 检测器进行人脸检测是一种传统的方式,下面将给出利用 OpenCV 中的 haarcascade 进行人脸检测的代码。 可选的人脸检测模型(区别是检测速度和精度不同

    2023年04月12日
    浏览(23)
  • Python使用pip安装mediapipe,实现计算机视觉的应用

    近年来,计算机视觉在人工智能领域蓬勃发展,为我们提供了许多强大的工具和技术。其中,mediapipe是一个广受欢迎的开源库,它提供了一整套计算机视觉算法和应用程序接口(API),帮助开发者轻松构建各种视觉相关的项目。本文将介绍如何使用pip安装mediapipe以及一些常见

    2024年02月04日
    浏览(11)
  • 改良YOLOv8网络架构 | 采用SwinTransformer网络 | 借助位移窗口实现视觉变换 | 计算机视觉

    改良YOLOv8网络架构 | 采用SwinTransformer网络 | 借助位移窗口实现视觉变换 | 计算机视觉 随着计算机视觉技术的不断发展,研究人员们也在不断尝试对各种神经网络进行改良,以提高它们的性能和准确度。其中比较流行的一个目标检测算法就是YOLOv8,但是它依然存在一些不足之处

    2024年02月08日
    浏览(15)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包