import torch
import os
import numpy as np
from PIL import Image
def cal_mean_std(path: str):
channels_sum, channels_squared_sum, nums = 0, 0, 0
path_list = os.listdir(path)
for img_path in path_list:
image_path = os.path.join(path, img_pat服务器托管网h)
image = Image.open(image_path)
if image.mode != 'RGB':
image = image.convert('RGB') # convert image to RGB if it is not
image = torch.from_numpy(np.array(image)).permute([2, 0, 1]).float()
ch服务器托管网annels_sum += torch.mean(image, dim=[1, 2])
channels_squared_sum += torch.mean(image**2, dim=[1, 2])
nums += 1
mean = channels_sum / nums
std = (channels_squared_sum / nums - mean**2)**0.5
return mean, std
if __name__ == '__main__':
path = os.path.abspath(r"C:UsersGWDesktopxudata_cocotrain2017") # 数据集路径
mean, std = cal_mean_std(path=path)
print(f'mean : {mean}, std : {std}')
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: Lnton 羚通智能分析算法河道水位标尺识别预警
河道水位标尺识别预警系统服务器托管网通过 python+yolov8网络模型技术,河道水位标尺识别预警算法对河道水位标尺进行实时监测,当河道水位出现异常情况时,河道水位标尺识别预警算法将自动发出警报提示后台管理人员及时采取措施。YOLO 系列算法是一类典型的 …