程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Implementation of online random resize during Python tool method 27 training (supporting image classification and semantic segmentation)

編輯:Python

In the training process, dynamically adjusting the size of data can enhance the model's adaptability to different conditions size The adaptability of size objects , It is a means to improve the generalization ability of the model . If in paddledection In kit , It provides a variety of parameter settings size Combine ; Besides , Bloggers are reading SegFormer Model paper , The author also mentioned the use of 0.5-2.0 Scale the training data at the magnification of ( The author's operation also includes random horizontal flip and random clipping ). This operation is implemented for this purpose , For images resize Both use PIL.Image Realization and ai The framework has nothing to do with ,paddle、pytorch、tensorflwo You can use . Target detection is not supported for the time being , It will be improved if necessary in the future .

Remember in use , Conduct random_size when , Because you want to convert the picture to uint8, Therefore, the incoming data cannot be standardized ( Subtract the mean and divide the variance ), Only data that allows normalization is passed in . Otherwise, the performance will be extremely poor , The model doesn't converge ( There are negative numbers in the standardized data , turn uint8 There is information loss after )

1、 Concrete realization

1.1 resize Implementation of function

In the process of image processing resize when , It should be noted that label The format is WH, For two-dimensional data , and image The format is CWH or WHC For 3D data , Besides image It is also divided into single channel and three channels , The three channels are usually rgb data , The single channel is usually gray image data . Different functions need to be selected for different data resize operation , There are the following three functions .

from PIL import 

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved