xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 1KB
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發布日期: 2021-06-13
  • 語言: Python
  • 標簽: Mean??Std??

資源簡介

在利用深度學習開源代碼測試自己數據時,會遇到對自己構建數據集進行均值和方差計算的問題。本資源有兩個python腳本,在python3下編寫,一個是直接求取原始數據集均值,一個是對拉成張量后的數據集進行均值和方差求取處理,用于transforms.Normalize()函數設置。

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-
“““
Created?on?Mon?Apr?22?22:02:51?2019

@author:?MSIK
“““

import?os
import?numpy?as?np
import?cv2
from?tqdm?import?tqdm
?
#?calculate?means?and?std
filepath?=?‘D:/SemanticSegmentation/pytorch-semseg/datasets/VOC/VOC2019/JPEGImages‘
pathDir?=?os.listdir(filepath)


CNum?=?1000?????#?挑選多少圖片進行計算

#random.randint(lowhighsize)
filenameArray?=?np.random.randint(1len(pathDir)CNum)
?
img_h?img_w?=?256?256
imgs?=?np.zeros([img_w?img_h?3?1])
means?stdevs?=?[]?[]
?
#for?idx?in?tqdm(range(len(pathDir))):
for?idx?in?tqdm(range(CNum)):
????filename?=?pathDir[idx]
????img_path?=?os.path.join(filepath?filename)
?
????img?=?cv2.imread(img_path)
????img?=?cv2.resize(img?(img_h?img_w))
????img?=?img[:?:?:?np.newaxis]
????
????imgs?=?np.concatenate((imgs?img)?axis=3)
#?????????print(i)
?
imgs?=?imgs.astype(np.float32)/255.
?
?
for?i?in?tqdm(range(3)):
????pixels?=?imgs[::i:].ravel()
????means.append(np.mean(pixels))
????stdevs.append(np.std(pixels))
?
#?cv2?讀取的圖像格式為BGR,PIL/Skimage讀取到的都是RGB不用轉
means.reverse()?#?BGR?-->?RGB
stdevs.reverse()
?
print(“normMean?=?{}“.format(means))
print(“normStd?=?{}“.format(stdevs))
print(‘transforms.Normalize(normMean?=?{}?normStd?=?{})‘.format(means?stdevs))

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1349??2019-04-24?20:39??main_GetMeanandStd.py
?????文件?????????835??2019-04-22?00:07??main_GetMeanValue.py

評論

共有 條評論