利用模型算法部署图像识别_利用这些技巧增强您的图像识别模型

本文探讨如何通过各种技巧增强图像识别模型的性能。内容包括模型算法的优化和部署策略,旨在帮助开发者提高其在图像识别任务中的准确性和效率。
摘要由CSDN通过智能技术生成

利用模型算法部署图像识别

So, you have gathered a dataset, built a neural network, and trained your model.

因此,您已经收集了数据集,建立了神经网络并训练了模型。

But despite the hours (and sometimes days) of work you invested to create the model, it spits out predictions with an accuracy of 50–70%. Chances are, this is not what you expected.

但是,尽管您花费了数小时(有时是数天)来创建模型,但它仍能以50%至70%的准确性发出预测。 很有可能,这不是您所期望的。

Here are a few strategies, or hacks, to boost your model’s performance metrics.

这里有一些策略或技巧,可以提高模型的性能指标。

1.获取更多数据 (1. Get More Data)

Deep learning models are only as powerful as the data you bring in. One of the easiest ways to increase validation accuracy is to add more data. This is especially useful if you don’t have many training instances.

深度学习模型仅具有所引入数据的功能。提高验证准确性的最简单方法之一就是添加更多数据。 如果您没有很多训练实例,这将特别有用。

If you’re working on image recognition models, you may consider increasing the diversity of your available dataset by employing data augmentation. These techniques include anything from flipping an image over an axis and adding noise to zooming in on the image. If you are a strong machine learning engineer, you could also try data augmentation with GANs.

如果您正在使用图像识别模型,则可以考虑通过使用数据增强来增加可用数据集的多样性。 这些技术包括从在轴上翻转图像到增加噪声到放大图像的一切。 如果您是一位强大的机器学习工程师,则还可以尝试使用GAN进行数据增强。

Read more about data augmentation here.

在此处阅读有关数据增强的更多信息。

Keras has an amazing image preprocessing class to perform data augmentation: ImageDataGenerator.

Keras有一个惊人的图像预处理类来执行数据增强: ImageDataGenerator

Image for post
Source 资源

2.添加更多层(2. Add More Layers)

Adding more layers to your model increases its ability to learn your dataset’s features more deeply, and hence it will be able to recognize subtle differences that you, as a human, might not have picked up on.

在模型中添加更多层可以提高其更深入地学习数据集特征的能力,因此它能够识别出您作为人类可能尚未发现的细微差别。

This hack entirely relies on the nature of the task you are trying to solve.

此hack完全取决于您要解决的任务的性质。

For complex tasks, such as differentiating between the breeds of cats and dogs, adding more layers makes sense because your model will be able to learn the subtle features that differentiate a poodle from a shih tzu.

对于复杂的任务,例如区分品种 对于猫和狗,增加更多的层次是有道理的,因为您的模型将能够学习区分贵宾犬和西施犬的细微特征。

For simple tasks, such as classifying cats and dogs, a simple model with few layers will do.

对于简单的任务(例如对猫和狗进行分类),将需要一个具有很少层的简单模型。

More layers -> More nuanced model

更多图层->更细微的模型

Image for post
Photo by Alvan Nee on Unsplash
Alvan NeeUnsplash上的 照片

3.更改图像大小(3. Change Your Image Size)

When you preprocess your images for training and evaluation, there is a lot of experimentation to be done with regards to the image size.

在对图像进行预处理以进行训练和评估时,需要对图像大小进行大量实验。

If you choose an image size that is too small, your model will not be able to pick up on the distinctive features that help with image recognition.

如果选择的图像尺寸太小,模型将无法使用有助于图像识别的独特功能。

Conversely, if your images are too big, it increases the computational resources required by your computer and/or your model might not be sophisticated enough to process them.

相反,如果图像太大,则会增加计算机所需的计算资源,并且/或者您的模型可能不够复杂,无法处理它们。

Common image sizes include 64x64, 128x128, 28x28 (MNIST) and 224x224 (VGG-16).

常见的图片大小包括64x64、128x128、28x28(MNIST)和224x224(VGG-16)。

Keep in mind that most preprocessing algorithms do not consider the aspect ratio of the image, so smaller-sized images might appear to have shrunk over a certain axis.

请记住,大多数预处理算法都没有考虑图像的长宽比,因此较小尺寸的图像可能会在特定轴上收缩。

Image for post
Source 资源

4.增加时代(4. Increase Epochs)

Epochs are basically how many times you pass the entire dataset through the neural network. Incrementally train your model with more epochs with intervals of +25, +100, and so on.

基本上,历元是您将整个数据集通过神经网络传递的次数。 以+ 25,+ 100等为间隔,以更多的时期递增地训练模型。

Increasing epochs makes sense only if you have a lot of data in your dataset. However, your model will eventually reach a point where increasing epochs will not improve accuracy.

仅当数据集中有大量数据时,增加历元才有意义。 但是,您的模型最终会达到增加历时不会提高准确性的地步。

At this point, you should consider playing around with your model’s learning rate. This little hyperparameter dictates whether your model reaches its global minimum (the ultimate goal for neural nets) or gets stuck in a local minimum.

此时,您应该考虑调整模型的学习率。 这个小超参数指示您的模型是达到其全局最小值(神经网络的最终目标)还是被困在局部 最低。

Image for post
Source 资源

5.减少色彩通道(5. Decrease Colour Channels)

Colour channels reflect the dimensionality of your image arrays. Most colour (RGB) images are composed of three colour channels, while grayscale images have just one channel.

颜色通道反映了图像阵列的尺寸。 大多数彩色(RGB)图像由三个颜色通道组成,而灰度图像只有一个通道。

The more complex the colour channels are, the more complex the dataset is and the longer it will take to train the model.

颜色通道越复杂,数据集越复杂,训练模型所需的时间也越长。

If colour is not such a significant factor in your model, you can go ahead and convert your colour images to grayscale.

如果颜色不是模型中的重要因素,则可以继续将彩色图像转换为灰度。

You can even consider other colour spaces, like HSV and L*a*b.

您甚至可以考虑其他颜色空间,例如HSV和L * a * b。

Image for post
Source 资源

6.转移学习(6. Transfer Learning)

Transfer learning involves the use of a pre-trained model, such as YOLO and ResNet, as a starting point for most computer vision and natural language processing tasks.

迁移学习涉及使用诸如YOLO和ResNet之类的预训练模型,作为大多数计算机视觉和自然语言处理任务的起点。

Pre-trained models are state-of-the-art deep learning models that were trained on millions and millions of samples, and often for months. These models have an astonishingly huge capability of detecting nuances in different images.

预先训练的模型是最先进的深度学习模型,对数百万个样本进行了训练,而且通常需要几个月的时间。 这些模型具有惊人的巨大能力,可以检测不同图像中的细微差别。

These models can be used as a base for your model. Most models are so good that you won’t need to add convolutional and pooling Layers.

这些模型可以用作模型的基础。 大多数模型都非常好,您无需添加卷积和池化层。

Read more about using transfer learning.

阅读有关使用转移学习的更多信息。

Image for post
Nvidia blog Nvidia博客

7.额外(7. Extra)

The hacks above offer a base for you to optimize a model. To really finetune a model, you’ll need to consider tuning the various hyperparameters and functions involved in your model, such as the learning rate (as discussed above), activation functions, loss functions, etc.

上面的技巧为您优化模型提供了基础。 要真正微调模型,您需要考虑调整模型中涉及的各种超参数和函数,例如学习率(如上所述),激活函数,损失函数等。

This hack comes as an “I hope you know what you’re doing” warning because there is a wider scope to mess up your model.

这种破解是“我希望您知道自己在做什么”的警告,因为存在更大的范围来弄乱您的模型。

小费 (Tip)

Always save your model every time you make a change to your deep learning model. This will help you reuse a previous configuration of the model if it provides greater accuracy.

每次更改深度学习模型时,请始终保存模型。 如果模型提供了更高的准确性,这将帮助您重用模型的先前配置。

Most deep learning frameworks like Tensorflow and Pytorch have a “save model” method.

大多数深度学习框架(例如Tensorflow和Pytorch)都具有“保存模型”方法。

# In Tensorflow
model.save('model.h5') # Saves the entire model to a single artifact# In Pytorch
torch.save(model, PATH)

There are countless other ways to further optimize your deep learning, but the hacks described above serve as a base in the optimization part of deep learning.

还有无数其他方法可以进一步优化您的深度学习,但上述技巧是深度学习优化部分的基础。

Let me know what your favourite hack is!

让我知道您最喜欢的黑客是什么!

翻译自: https://levelup.gitconnected.com/supercharge-your-image-recognition-models-with-these-hacks-a0fb6bf6c79

利用模型算法部署图像识别

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值