diff --git a/.gitignore b/.gitignore index 6bc7e2b..f42bd93 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,6 @@ fabric.properties /20240627Actual_deployed/qt_test/ /20240627Actual_deployed/qt_test/PF/ /20240627Actual_deployed/image/ +/20240627Actual_deployed/pfzc/ +/20240627Actual_deployed/pfzz/ +/20240529RGBtest3/原图108测试过程图/ diff --git a/.idea/.name b/.idea/.name index 11a5d8e..4c5bcef 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -main.py \ No newline at end of file +pic.py \ No newline at end of file diff --git a/20240529RGBtest3/classifer.py b/20240529RGBtest3/classifer.py index 70abbdd..7a6974c 100644 --- a/20240529RGBtest3/classifer.py +++ b/20240529RGBtest3/classifer.py @@ -569,6 +569,7 @@ class Data_processing: org_defect = tomato.bitwise_and_rgb_with_binary(edge, new_bin_img) fore = tomato.bitwise_and_rgb_with_binary(img, mask) fore_g_r_t = tomato.threshold_segmentation(tomato.extract_g_r(fore), threshold=setting.threshold_fore_g_r_t) + filled_img_nogreen = cv2.bitwise_or(filled_img, fore_g_r_t) res = cv2.bitwise_or(new_bin_img, fore_g_r_t) nogreen = tomato.bitwise_and_rgb_with_binary(edge, res) # 统计白色像素点个数 @@ -583,7 +584,7 @@ class Data_processing: # 获取西红柿的尺寸信息 long_axis, short_axis = self.analyze_ellipse(mask) # 获取缺陷信息 - number_defects, total_pixels = self.analyze_defect(filled_img) + number_defects, total_pixels = self.analyze_defect(filled_img_nogreen) # print(filled_img.shape) # print(f'缺陷数量:{number_defects}; 缺陷总面积:{total_pixels}') # cv2.imwrite('filled_img.jpg',filled_img) diff --git a/20240529RGBtest3/tg/pic.py b/20240529RGBtest3/tg/pic.py new file mode 100644 index 0000000..ce09650 --- /dev/null +++ b/20240529RGBtest3/tg/pic.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# @Time : 2024/7/4 下午10:43 +# @Author : TG +# @File : pic.py +# @Software: PyCharm +import os + + +def rename_bmp_images(folder_path, new_name_format): + # 获取文件夹中的所有文件 + files = os.listdir(folder_path) + # 过滤出BMP图像文件 + bmp_files = [f for f in files if f.lower().endswith('.bmp')] + + # 对每个BMP图像文件进行重命名 + for index, bmp_file in enumerate(bmp_files): + old_path = os.path.join(folder_path, bmp_file) + new_name = new_name_format.format(index + 1) + new_path = os.path.join(folder_path, new_name) + + # 重命名文件 + os.rename(old_path, new_path) + print(f'Renamed {old_path} to {new_path}') + + +# 指定文件夹路径和新的命名格式 +folder_path = r'D:\桌面文件\裂口数据集扩充(4月份数据补充)\scar' +new_name_format = 'scar_{:03d}.bmp' # 例如,image_001.bmp, image_002.bmp, ... + +# 调用函数进行重命名 +rename_bmp_images(folder_path, new_name_format) diff --git a/20240529RGBtest3/tg/split_data.py b/20240529RGBtest3/tg/split_data.py new file mode 100644 index 0000000..dbba42d --- /dev/null +++ b/20240529RGBtest3/tg/split_data.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# @Time : 2024/7/11 下午3:08 +# @Author : TG +# @File : split_data.py +# @Software: PyCharm +import os +import random +import shutil +from pathlib import Path + +# 设置数据集目录 +dataset_path = Path(r'F:\0711_lk') +images = list(dataset_path.glob('*.bmp')) # 假设图像文件是jpg格式 + +# 设置随机种子以保证结果可复现 +random.seed(42) + +# 打乱数据集 +random.shuffle(images) + +# 计算划分点 +num_images = len(images) +train_split = int(num_images * 0.6) +val_split = int(num_images * 0.8) + +# 分割数据集 +train_images = images[:train_split] +val_images = images[train_split:val_split] +test_images = images[val_split:] + +# 创建保存分割后数据集的文件夹 +(train_path, val_path, test_path) = [dataset_path.parent / x for x in ['train', 'val', 'test']] +for path in [train_path, val_path, test_path]: + path.mkdir(exist_ok=True) + +# 定义一个函数来复制图像和标签文件 +def copy_files(files, dest_folder): + for file in files: + shutil.copy(file, dest_folder) + label_file = file.with_suffix('.txt') + if label_file.exists(): + shutil.copy(label_file, dest_folder) + +# 复制文件到新的文件夹 +copy_files(train_images, train_path) +copy_files(val_images, val_path) +copy_files(test_images, test_path) + +print("数据集划分完成。训练集、验证集和测试集已经被保存到对应的文件夹。") diff --git a/20240529RGBtest3/xs/image_preprocessing20240615.py b/20240529RGBtest3/xs/image_preprocessing20240615.py index d3f96fc..6e70d26 100644 --- a/20240529RGBtest3/xs/image_preprocessing20240615.py +++ b/20240529RGBtest3/xs/image_preprocessing20240615.py @@ -211,7 +211,8 @@ def extract_max_connected_area(image_path, lower_hsv, upper_hsv): def main(): parser = argparse.ArgumentParser(description='Process some integers.') - parser.add_argument('--dir_path', type=str, default=r'D:\project\supermachine--tomato-passion_fruit\20240529RGBtest3\data\qt_test\TO\TOzhengchangyoudeng', + parser.add_argument('--dir_path', type=str, + default=r'D:\project\supermachine--tomato-passion_fruit\20240529RGBtest3\data\20270708\T2\middle', help='the directory path of images') parser.add_argument('--threshold_s_l', type=int, default=180, help='the threshold for s_l') @@ -247,8 +248,8 @@ def main(): fore_g_r_t = threshold_segmentation(extract_g_r(fore), 20) - filled_img1 = cv2.bitwise_or(filled_img, fore_g_r_t) - cv2.imshow('filled_img1', filled_img1) + filled_img_nogreen = cv2.bitwise_or(filled_img, fore_g_r_t) + cv2.imshow('filled_img_nogreen', filled_img_nogreen) #统计白色像素点个数 print(np.sum(fore_g_r_t == 255)) print(np.sum(mask == 255)) diff --git a/20240627Actual_deployed/classifer.py b/20240627Actual_deployed/classifer.py index e8754d4..2bceeb1 100644 --- a/20240627Actual_deployed/classifer.py +++ b/20240627Actual_deployed/classifer.py @@ -5,6 +5,8 @@ # @Software: PyCharm import os +import time + import cv2 import pipe_utils import joblib @@ -14,7 +16,7 @@ import numpy as np from pipe_utils import Pipe from config import Config as setting from sklearn.ensemble import RandomForestRegressor -from detector import run +from detector import Detector_to import torch import torch.nn as nn @@ -389,6 +391,174 @@ class Spec_predict(object): data_y = self.model.predict(data_x) return data_y[0] + +class BasicBlock(nn.Module): + ''' + BasicBlock for ResNet18 and ResNet34 + + ''' + expansion = 1 + + def __init__(self, in_channel, out_channel, stride=1, downsample=None, **kwargs): + super(BasicBlock, self).__init__() + self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel, + kernel_size=3, stride=stride, padding=1, bias=False) + self.bn1 = nn.BatchNorm2d(out_channel) + self.relu = nn.ReLU() + self.conv2 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel, + kernel_size=3, stride=1, padding=1, bias=False) + self.bn2 = nn.BatchNorm2d(out_channel) + self.downsample = downsample + + def forward(self, x): + identity = x + if self.downsample is not None: + identity = self.downsample(x) + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + + out += identity + out = self.relu(out) + + return out + +class ResNet(nn.Module): + ''' + ResNet18 and ResNet34 + ''' + def __init__(self, + block, + blocks_num, + num_classes=1000, + include_top=True, + groups=1, + width_per_group=64): + super(ResNet, self).__init__() + self.include_top = include_top + self.in_channel = 64 + + self.groups = groups + self.width_per_group = width_per_group + + self.conv1 = nn.Conv2d(3, self.in_channel, kernel_size=7, stride=2, + padding=3, bias=False) + self.bn1 = nn.BatchNorm2d(self.in_channel) + self.relu = nn.ReLU(inplace=True) + self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) + self.layer1 = self._make_layer(block, 64, blocks_num[0]) + self.layer2 = self._make_layer(block, 128, blocks_num[1], stride=2) + self.layer3 = self._make_layer(block, 256, blocks_num[2], stride=2) + self.layer4 = self._make_layer(block, 512, blocks_num[3], stride=2) + if self.include_top: + self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) # output size = (1, 1) + self.fc = nn.Linear(512 * block.expansion, num_classes) + + for m in self.modules(): + if isinstance(m, nn.Conv2d): + nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') + + def _make_layer(self, block, channel, block_num, stride=1): + downsample = None + if stride != 1 or self.in_channel != channel * block.expansion: + downsample = nn.Sequential( + nn.Conv2d(self.in_channel, channel * block.expansion, kernel_size=1, stride=stride, bias=False), + nn.BatchNorm2d(channel * block.expansion)) + + layers = [] + layers.append(block(self.in_channel, + channel, + downsample=downsample, + stride=stride, + groups=self.groups, + width_per_group=self.width_per_group)) + self.in_channel = channel * block.expansion + + for _ in range(1, block_num): + layers.append(block(self.in_channel, + channel, + groups=self.groups, + width_per_group=self.width_per_group)) + + return nn.Sequential(*layers) + + def forward(self, x): + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + x = self.maxpool(x) + + x = self.layer1(x) + x = self.layer2(x) + x = self.layer3(x) + x = self.layer4(x) + + if self.include_top: + x = self.avgpool(x) + x = torch.flatten(x, 1) + x = self.fc(x) + + return x + +def resnet18(num_classes=1000, include_top=True): + return ResNet(BasicBlock, [2, 2, 2, 2], num_classes=num_classes, include_top=include_top) + +def resnet34(num_classes=1000, include_top=True): + return ResNet(BasicBlock, [3, 4, 6, 3], num_classes=num_classes, include_top=include_top) + +#百香果褶皱判别模型 +class ImageClassifier: + ''' + 图像分类器,用于加载预训练的 ResNet 模型并进行图像分类。 + ''' + def __init__(self, model_path, class_indices_path, device=None): + if device is None: + self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") + else: + self.device = device + + # 加载类别索引 + assert os.path.exists(class_indices_path), f"File: '{class_indices_path}' does not exist." + with open(class_indices_path, "r") as json_file: + self.class_indict = json.load(json_file) + + # 创建模型并加载权重 + self.model = resnet18(num_classes=len(self.class_indict)).to(self.device) + assert os. path.exists(model_path), f"File: '{model_path}' does not exist." + self.model.load_state_dict(torch.load(model_path, map_location=self.device)) + self.model.eval() + + # 设置图像转换 + self.transform = transforms.Compose([ + transforms.Resize(256), + transforms.CenterCrop(224), + transforms.ToTensor(), + transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) + ]) + + def predict(self, image_np): + ''' + 对图像进行分类预测。 + :param image_np: + :return: + ''' + # 将numpy数组转换为图像 + image = Image.fromarray(image_np.astype('uint8'), 'RGB') + image = self.transform(image).unsqueeze(0).to(self.device) + + with torch.no_grad(): + output = self.model(image).cpu() + predict = torch.softmax(output, dim=1) + predict_cla = torch.argmax(predict, dim=1).numpy() + + # return self.class_indict[str(predict_cla[0])] + return predict_cla[0] + + #数据处理模型 class Data_processing: def __init__(self, area_threshold=20000, density = 0.652228972, area_ratio=0.00021973702422145334): @@ -534,7 +704,7 @@ class Data_processing: # 获取西红柿的尺寸信息 long_axis, short_axis = self.analyze_ellipse(mask) # 获取缺陷信息 - number_defects, total_pixels = self.analyze_defect(filled_img_nogreen) + _, total_pixels = self.analyze_defect(filled_img_nogreen) # print(filled_img.shape) # print(f'缺陷数量:{number_defects}; 缺陷总面积:{total_pixels}') # cv2.imwrite('filled_img.jpg',filled_img) @@ -552,7 +722,7 @@ class Data_processing: # total_pixels = 0 # rp = cv2.cvtColor(np.ones((setting.n_rgb_rows, setting.n_rgb_cols, setting.n_rgb_bands), # dtype=np.uint8), cv2.COLOR_BGR2RGB) - return diameter, green_percentage, number_defects, total_pixels, rp + return diameter, green_percentage, total_pixels, rp def analyze_passion_fruit(self, img): if img is None: @@ -586,7 +756,7 @@ class Data_processing: if weight > 255: weight = random.randint(30, 65) - number_defects, total_pixels = self.analyze_defect(filled_img) + _, total_pixels = self.analyze_defect(filled_img) # img1 = img.copy() edge = pf.draw_contours_on_image(img, contour_mask) org_defect = pf.bitwise_and_rgb_with_binary(edge, max_mask) @@ -594,7 +764,7 @@ class Data_processing: #直径单位为cm # diameter = (long_axis + short_axis) * setting.pixel_length_ratio / 2 diameter = long_axis * setting.pixel_length_ratio - print(f'长径:{long_axis}像素;短径:{short_axis}像素;直径:{diameter}cm') + # print(f'长径:{long_axis}像素;短径:{short_axis}像素;直径:{diameter}cm') # if diameter < 2.5: # diameter = 0 # green_percentage = 0 @@ -603,9 +773,10 @@ class Data_processing: # total_pixels = 0 # rp = cv2.cvtColor(np.ones((setting.n_rgb_rows, setting.n_rgb_cols, setting.n_rgb_bands), # dtype=np.uint8), cv2.COLOR_BGR2RGB) - return diameter, green_percentage, weight, number_defects, total_pixels, rp + return diameter, green_percentage, weight, total_pixels, rp - def process_data(seif, cmd: str, images: list, spec: any, pipe: Pipe, detector: Spec_predict) -> bool: + def process_data(seif, cmd: str, images: list, spec: any, pipe: Pipe, + detector: Spec_predict, to: Detector_to, impf: ImageClassifier) -> bool: """ 处理指令 @@ -624,8 +795,11 @@ class Data_processing: for i, img in enumerate(images): if cmd == 'TO': # 番茄 - diameter, green_percentage, number_defects, total_pixels, rp = seif.analyze_tomato(img) - posun_num = run(img) + diameter, green_percentage, total_pixels, rp = seif.analyze_tomato(img) + ss = time.time() + posun_num = to.run(img) + es = time.time() + print(f'破损判断时间:{es-ss}') print(f'破损判断:{posun_num}') if i <= 2: diameter_axis_list.append(diameter) @@ -635,19 +809,20 @@ class Data_processing: if i == 1: rp_result = rp gp = round(green_percentage, 2) - max_defect_num = sum(ps) + ps_sum = sum(ps) elif cmd == 'PF': # 百香果 - diameter, green_percentage, weight, number_defects, total_pixels, rp = seif.analyze_passion_fruit(img) + diameter, green_percentage, weight, total_pixels, rp = seif.analyze_passion_fruit(img) if i <= 2: diameter_axis_list.append(diameter) - max_defect_num = max(max_defect_num, number_defects) + # max_defect_num = max(max_defect_num, number_defects) max_total_defect_area = max(max_total_defect_area, total_pixels) if i == 1: rp_result = rp weight = weight gp = round(green_percentage, 2) + zz_sum = int(impf.predict(img)) else: logging.error(f'错误指令,指令为{cmd}') @@ -662,14 +837,14 @@ class Data_processing: if diameter < 2.5: diameter = 0 gp = 0 - max_defect_num = 0 + ps_sum = 0 max_total_defect_area = 0 rp_result = cv2.cvtColor(np.ones((setting.n_rgb_rows, setting.n_rgb_cols, setting.n_rgb_bands), dtype=np.uint8), cv2.COLOR_BGR2RGB) print(f'预测的brix值为:{brix}; 预测的直径为:{diameter}; 预测的重量为:{weight}; 预测的绿色比例为:{gp};' - f' 预测的缺陷数量为:{max_defect_num}; 预测的总缺陷面积为:{max_total_defect_area};') + f' 破损判别结果为:{ps_sum}; 预测的总缺陷面积为:{max_total_defect_area};') response = pipe.send_data(cmd=cmd, brix=brix, diameter=diameter, green_percentage=gp, weight=weight, - defect_num=max_defect_num, total_defect_area=max_total_defect_area, rp=rp_result) + defect_num=ps_sum, total_defect_area=max_total_defect_area, rp=rp_result) return response elif cmd == 'PF': brix = detector.predict(spec) @@ -678,179 +853,14 @@ class Data_processing: diameter = 0 gp = 0 weight = 0 - max_defect_num = 0 + zz_sum = 0 max_total_defect_area = 0 rp_result = cv2.cvtColor(np.ones((setting.n_rgb_rows, setting.n_rgb_cols, setting.n_rgb_bands), dtype=np.uint8), cv2.COLOR_BGR2RGB) print(f'预测的brix值为:{brix}; 预测的直径为:{diameter}; 预测的重量为:{weight}; 预测的绿色比例为:{green_percentage};' - f' 预测的缺陷数量为:{max_defect_num}; 预测的总缺陷面积为:{max_total_defect_area};') + f' 褶皱判别结果为:{zz_sum}; 预测的总缺陷面积为:{max_total_defect_area};') response = pipe.send_data(cmd=cmd, brix=brix, green_percentage=gp, diameter=diameter, weight=weight, - defect_num=max_defect_num, total_defect_area=max_total_defect_area, rp=rp_result) + defect_num=zz_sum, total_defect_area=max_total_defect_area, rp=rp_result) return response -class BasicBlock(nn.Module): - ''' - BasicBlock for ResNet18 and ResNet34 - - ''' - expansion = 1 - - def __init__(self, in_channel, out_channel, stride=1, downsample=None, **kwargs): - super(BasicBlock, self).__init__() - self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel, - kernel_size=3, stride=stride, padding=1, bias=False) - self.bn1 = nn.BatchNorm2d(out_channel) - self.relu = nn.ReLU() - self.conv2 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel, - kernel_size=3, stride=1, padding=1, bias=False) - self.bn2 = nn.BatchNorm2d(out_channel) - self.downsample = downsample - - def forward(self, x): - identity = x - if self.downsample is not None: - identity = self.downsample(x) - - out = self.conv1(x) - out = self.bn1(out) - out = self.relu(out) - - out = self.conv2(out) - out = self.bn2(out) - - out += identity - out = self.relu(out) - - return out - -class ResNet(nn.Module): - ''' - ResNet18 and ResNet34 - ''' - def __init__(self, - block, - blocks_num, - num_classes=1000, - include_top=True, - groups=1, - width_per_group=64): - super(ResNet, self).__init__() - self.include_top = include_top - self.in_channel = 64 - - self.groups = groups - self.width_per_group = width_per_group - - self.conv1 = nn.Conv2d(3, self.in_channel, kernel_size=7, stride=2, - padding=3, bias=False) - self.bn1 = nn.BatchNorm2d(self.in_channel) - self.relu = nn.ReLU(inplace=True) - self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) - self.layer1 = self._make_layer(block, 64, blocks_num[0]) - self.layer2 = self._make_layer(block, 128, blocks_num[1], stride=2) - self.layer3 = self._make_layer(block, 256, blocks_num[2], stride=2) - self.layer4 = self._make_layer(block, 512, blocks_num[3], stride=2) - if self.include_top: - self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) # output size = (1, 1) - self.fc = nn.Linear(512 * block.expansion, num_classes) - - for m in self.modules(): - if isinstance(m, nn.Conv2d): - nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') - - def _make_layer(self, block, channel, block_num, stride=1): - downsample = None - if stride != 1 or self.in_channel != channel * block.expansion: - downsample = nn.Sequential( - nn.Conv2d(self.in_channel, channel * block.expansion, kernel_size=1, stride=stride, bias=False), - nn.BatchNorm2d(channel * block.expansion)) - - layers = [] - layers.append(block(self.in_channel, - channel, - downsample=downsample, - stride=stride, - groups=self.groups, - width_per_group=self.width_per_group)) - self.in_channel = channel * block.expansion - - for _ in range(1, block_num): - layers.append(block(self.in_channel, - channel, - groups=self.groups, - width_per_group=self.width_per_group)) - - return nn.Sequential(*layers) - - def forward(self, x): - x = self.conv1(x) - x = self.bn1(x) - x = self.relu(x) - x = self.maxpool(x) - - x = self.layer1(x) - x = self.layer2(x) - x = self.layer3(x) - x = self.layer4(x) - - if self.include_top: - x = self.avgpool(x) - x = torch.flatten(x, 1) - x = self.fc(x) - - return x - -def resnet18(num_classes=1000, include_top=True): - return ResNet(BasicBlock, [2, 2, 2, 2], num_classes=num_classes, include_top=include_top) - -def resnet34(num_classes=1000, include_top=True): - return ResNet(BasicBlock, [3, 4, 6, 3], num_classes=num_classes, include_top=include_top) - -#图像有无果判别模型 -class ImageClassifier: - ''' - 图像分类器,用于加载预训练的 ResNet 模型并进行图像分类。 - ''' - def __init__(self, model_path, class_indices_path, device=None): - if device is None: - self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") - else: - self.device = device - - # 加载类别索引 - assert os.path.exists(class_indices_path), f"File: '{class_indices_path}' does not exist." - with open(class_indices_path, "r") as json_file: - self.class_indict = json.load(json_file) - - # 创建模型并加载权重 - self.model = resnet34(num_classes=len(self.class_indict)).to(self.device) - assert os. path.exists(model_path), f"File: '{model_path}' does not exist." - self.model.load_state_dict(torch.load(model_path, map_location=self.device)) - self.model.eval() - - # 设置图像转换 - self.transform = transforms.Compose([ - transforms.Resize(256), - transforms.CenterCrop(224), - transforms.ToTensor(), - transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) - ]) - - def predict(self, image_np): - ''' - 对图像进行分类预测。 - :param image_np: - :return: - ''' - # 将numpy数组转换为图像 - image = Image.fromarray(image_np.astype('uint8'), 'RGB') - image = self.transform(image).unsqueeze(0).to(self.device) - - with torch.no_grad(): - output = self.model(image).cpu() - predict = torch.softmax(output, dim=1) - predict_cla = torch.argmax(predict, dim=1).numpy() - - # return self.class_indict[str(predict_cla[0])] - return predict_cla[0] \ No newline at end of file diff --git a/20240627Actual_deployed/config.py b/20240627Actual_deployed/config.py index 433dfb0..294e90b 100644 --- a/20240627Actual_deployed/config.py +++ b/20240627Actual_deployed/config.py @@ -17,9 +17,11 @@ class Config: #糖度模型 brix_model_path = ROOT_DIR / 'models' / 'passion_fruit.joblib' #图像分类模型 - imgclassifier_model_path = ROOT_DIR / 'models' / 'resnet18pf.pth' + imgclassifier_model_path = ROOT_DIR / 'models' / 'resnet18pf20240705.pth' imgclassifier_class_indices_path = ROOT_DIR / 'models' / 'class_indices.json' + #番茄破损模型 + tomato_model_path = ROOT_DIR / 'weights' / 'best.pt' #classifer.py参数 #tomato diff --git a/20240627Actual_deployed/detector.py b/20240627Actual_deployed/detector.py index eff47a0..0a65ed6 100644 --- a/20240627Actual_deployed/detector.py +++ b/20240627Actual_deployed/detector.py @@ -12,43 +12,38 @@ from utils.general import ( ) from utils.torch_utils import select_device, smart_inference_mode from utils.dataloaders import letterbox +from config import Config as setting -@smart_inference_mode() -def run( - img, # numpy array - weights=Path(r'D:\porject\PY\20240627Actual_deployed\weights\best.pt'), # model path - imgsz=(640, 640), # inference size (height, width) - conf_thres=0.25, # confidence threshold - iou_thres=0.45, # NMS IOU threshold - max_det=1000, # maximum detections per image - device="0", # cuda device, i.e. 0 or 0,1,2,3 or cpu - half=False, # use FP16 half-precision inference -): - """Runs YOLOv5 detection inference on a numpy array and returns the number of detections.""" - # Load model - device = select_device(device) - model = DetectMultiBackend(weights, device=device, fp16=half) - stride = model.stride - imgsz = check_img_size(imgsz, s=stride) # check image size +class Detector_to: + def __init__(self, weights=Path(setting.tomato_model_path), + device="", half=False): + self.device = select_device(device) + self.model = DetectMultiBackend(weights, device=self.device, fp16=half) + self.stride = int(self.model.stride) # get stride from the model + self.fp16 = half - # Convert numpy array to tensor - img = letterbox(img, imgsz, stride=stride)[0] - img = img.transpose((2,0,1)) - img = np.ascontiguousarray(img) - im = torch.from_numpy(img).to(model.device) - im = im.half() if model.fp16 else im.float() # uint8 to fp16/32 - im /= 255 # 0 - 255 to 0.0 - 1.0 - if len(im.shape) == 3: - im = im[None] # expand for batch dim + def run(self, img, imgsz=(640, 640), conf_thres=0.25, iou_thres=0.45, max_det=1000): + """Runs YOLOv5 detection inference on a numpy array and returns the number of detections.""" + imgsz = check_img_size(imgsz, s=self.stride) # check image size - # Inference - pred = model(im) + # Convert numpy array to tensor + img = letterbox(img, imgsz, stride=self.stride)[0] # resize image to model expected size + img = img.transpose((2, 0, 1)) # HWC to CHW + img = np.ascontiguousarray(img) # make contiguous + im = torch.from_numpy(img).to(self.model.device) + im = im.half() if self.fp16 else im.float() # uint8 to fp16/32 + im /= 255 # 0 - 255 to 0.0 - 1.0 + if len(im.shape) == 3: + im = im[None] # expand for batch dim - # NMS - pred = non_max_suppression(pred, conf_thres, iou_thres, max_det=max_det) + # Inference + pred = self.model(im) - # Count detections - num_detections = sum([len(d) for d in pred if d is not None]) + # NMS + pred = non_max_suppression(pred, conf_thres, iou_thres, max_det=max_det) - return num_detections + # Count detections + num_detections = sum([len(d) for d in pred if d is not None]) + + return num_detections diff --git a/20240627Actual_deployed/main.py b/20240627Actual_deployed/main.py index 787d77b..712d320 100644 --- a/20240627Actual_deployed/main.py +++ b/20240627Actual_deployed/main.py @@ -16,7 +16,7 @@ from pipe_utils import Pipe import numpy as np from config import Config import time -from detector import run +from detector import Detector_to # from clspredict import runcls def main(is_debug=False): @@ -32,13 +32,24 @@ def main(is_debug=False): detector = Spec_predict() detector.load(path=setting.brix_model_path) dp = Data_processing() + to = Detector_to() + #impf为百香果褶皱判别模型,0为褶皱,1为正常 impf = ImageClassifier(model_path=setting.imgclassifier_model_path, - class_indices_path=setting.imgclassifier_class_indices_path) + class_indices_path=setting.imgclassifier_class_indices_path) print('系统初始化中...') #模型预热 + hh = time.time() #与qt_test测试时需要注释掉预热,模型接收尺寸为(25,30,13),qt_test发送的数据为(30,30,224),需要对数据进行切片(classifer.py第379行) _ = detector.predict(np.ones((setting.n_spec_rows, setting.n_spec_cols, setting.n_spec_bands), dtype=np.uint16)) + hk = time.time() + print(f'brix模型预热时间:{hk-hh}') + #run函数为番茄破损判别模型,返回0表示无破损,1、2、3即表示1、2、3处破损 + _ = to.run(np.ones((800, 613, 3), dtype=np.uint8)) + hi = time.time() + print(f'run模型预热时间:{hi-hk}') _ = impf.predict(np.ones((800, 613, 3), dtype=np.uint8)) + gg = time.time() + print(f'impf模型预热时间:{gg-hi}') time.sleep(1) print('系统初始化完成') @@ -59,20 +70,20 @@ def main(is_debug=False): #主循环 q = 1 while True: - # st = time.time() + st = time.time() #RGB图像部分 images = [] cmd = None for i in range(3): - # start_time = time.time() + start_time = time.time() data = pipe.receive_rgb_data(rgb_receive) - # end_time = time.time() - # print(f'接收第{q}个果子第{i+1}张图数据时间:{end_time-start_time}') + end_time = time.time() + print(f'接收第{q}个果子第{i+1}张图数据时间:{end_time-start_time}') print(f'接收第{q}个果子第{i+1}张图数据长度:{len(data)}') cmd, img = pipe.parse_img(data) - # end_time1 = time.time() + end_time1 = time.time() img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) - # print(f'解码第{q}个果子第{i + 1}张图数据时间:{end_time1 - end_time}') + print(f'解码第{q}个果子第{i + 1}张图数据时间:{end_time1 - end_time}') print(f'接收第{q}个果子第{i+1}张图:{img.shape}') # cv2.imwrite(f'./{q}_{i}.png', img) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) @@ -94,13 +105,21 @@ def main(is_debug=False): #Spec数据部分 spec = None if cmd == 'PF': + sp = time.time() spec_data = pipe.receive_spec_data(spec_receive) + ep = time.time() + print(f'接收到第{q}个果子的光谱数据时间:{ep-sp}') print(f'接收到第{q}个果子的光谱数据长度:{len(spec_data)}') _, spec = pipe.parse_spec(spec_data) + ep1 = time.time() + print(f'解码第{q}个果子的光谱数据时间:{ep1-ep}') print(f'接收到第{q}个果子的光谱数据尺寸:{spec.shape}') #数据处理部分 if images: # 确保images不为空 - response = dp.process_data(cmd, images, spec, pipe, detector) + sg = time.time() + response = dp.process_data(cmd, images, spec, pipe, detector, to, impf) + eg = time.time() + print(f'第{q}个果子数据处理时间:{eg-sg}') if response: logging.info(f'处理成功,响应为: {response}') else: @@ -109,8 +128,8 @@ def main(is_debug=False): logging.error("没有有效的图像进行处理") print(f'第{q}个果子处理完成') q += 1 - # end_time2 = time.time() - # print(f'第{q}个果子全流程时间:{end_time2-st}') + end_time2 = time.time() + print(f'第{q}个果子全流程时间:{end_time2-st}') if __name__ == '__main__': diff --git a/20240627Actual_deployed/models/class_indices.json b/20240627Actual_deployed/models/class_indices.json index 9ddf683..35e1dd7 100644 --- a/20240627Actual_deployed/models/class_indices.json +++ b/20240627Actual_deployed/models/class_indices.json @@ -1,4 +1,4 @@ { "0": "De", "1": "N" -} \ No newline at end of file +} diff --git a/20240627Actual_deployed/models/yolo.py b/20240627Actual_deployed/models/yolo.py index d89c5da..de9c301 100644 --- a/20240627Actual_deployed/models/yolo.py +++ b/20240627Actual_deployed/models/yolo.py @@ -186,7 +186,7 @@ class BaseModel(nn.Module): def fuse(self): """Fuses Conv2d() and BatchNorm2d() layers in the model to improve inference speed.""" - LOGGER.info("Fusing layers... ") + # LOGGER.info("Fusing layers... ") for m in self.model.modules(): if isinstance(m, (Conv, DWConv)) and hasattr(m, "bn"): m.conv = fuse_conv_and_bn(m.conv, m.bn) # update conv diff --git a/20240627Actual_deployed/qt_test.py b/20240627Actual_deployed/qt_test.py index 6b8208a..86b5edc 100644 --- a/20240627Actual_deployed/qt_test.py +++ b/20240627Actual_deployed/qt_test.py @@ -69,11 +69,11 @@ class MainWindow(QMainWindow): :param image_dir: bmp和raw文件所在文件夹 :return: ''' - rgb_files = [os.path.join(image_dir, f) for f in os.listdir(image_dir) if f.endswith(('.bmp'))][:5] - # spec_files = [os.path.join(image_dir, f) for f in os.listdir(image_dir) if f.endswith('.raw')][:1] + rgb_files = [os.path.join(image_dir, f) for f in os.listdir(image_dir) if f.endswith(('.bmp'))][:3] + spec_files = [os.path.join(image_dir, f) for f in os.listdir(image_dir) if f.endswith('.raw')][:1] self.send_YR() - for _ in range(5): + for _ in range(100): for image_path in rgb_files: img = cv2.imread(image_path, cv2.IMREAD_COLOR) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) @@ -96,29 +96,29 @@ class MainWindow(QMainWindow): except Exception as e: print(f"数据发送失败. 错误原因: {e}") - # if spec_files: - # spec_file = spec_files[0] - # with open(spec_file, 'rb') as f: - # spec_data = f.read() - # - # try: - # # win32file.WriteFile(self.spec_send, len(spec_data).to_bytes(4, byteorder='big')) - # # print(f"发送的光谱数据长度: {len(spec_data)}") - # heigth = 30 - # weight = 30 - # bands = 224 - # heigth = heigth.to_bytes(2, byteorder='big') - # weight = weight.to_bytes(2, byteorder='big') - # bands = bands.to_bytes(2, byteorder='big') - # length = (len(spec_data)+8).to_bytes(4, byteorder='big') - # # cmd = 'TO':测试番茄数据;cmd = 'PF':测试百香果数据 - # cmd = 'TO' - # data_send = length + cmd.upper().encode('ascii') + heigth + weight + bands + spec_data - # win32file.WriteFile(self.spec_send, data_send) - # print(f'发送的光谱数据长度: {len(data_send)}') - # print(f'spec长度: {len(spec_data)}') - # except Exception as e: - # print(f"数据发送失败. 错误原因: {e}") + if spec_files: + spec_file = spec_files[0] + with open(spec_file, 'rb') as f: + spec_data = f.read() + + try: + # win32file.WriteFile(self.spec_send, len(spec_data).to_bytes(4, byteorder='big')) + # print(f"发送的光谱数据长度: {len(spec_data)}") + heigth = 30 + weight = 30 + bands = 224 + heigth = heigth.to_bytes(2, byteorder='big') + weight = weight.to_bytes(2, byteorder='big') + bands = bands.to_bytes(2, byteorder='big') + length = (len(spec_data)+8).to_bytes(4, byteorder='big') + # cmd = 'TO':测试番茄数据;cmd = 'PF':测试百香果数据 + cmd = 'TO' + data_send = length + cmd.upper().encode('ascii') + heigth + weight + bands + spec_data + win32file.WriteFile(self.spec_send, data_send) + print(f'发送的光谱数据长度: {len(data_send)}') + print(f'spec长度: {len(spec_data)}') + except Exception as e: + print(f"数据发送失败. 错误原因: {e}") self.receive_result() diff --git a/20240627Actual_deployed/tomato-passion_fruit.log b/20240627Actual_deployed/tomato-passion_fruit.log index 31bd2bc..3935e3e 100644 --- a/20240627Actual_deployed/tomato-passion_fruit.log +++ b/20240627Actual_deployed/tomato-passion_fruit.log @@ -86,3 +86,81 @@ 2024-07-01 17:51:45,559 utils.py[line:230] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') 2024-07-01 17:51:45,559 main.py[line:101] - ERROR - 处理失败 2024-07-01 17:51:45,560 utils.py[line:84] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 14:08:48,265 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 14:08:48,265 main.py[line:108] - ERROR - 处理失败 +2024-07-04 14:08:49,453 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 14:08:49,453 main.py[line:108] - ERROR - 处理失败 +2024-07-04 14:08:50,744 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 14:08:50,744 main.py[line:108] - ERROR - 处理失败 +2024-07-04 14:08:50,744 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 14:27:19,068 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 16:41:47,465 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 16:45:24,931 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 16:49:02,620 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 16:51:48,679 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 16:53:58,252 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 17:00:49,493 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 17:08:10,792 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:10,793 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:12,041 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:12,042 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:13,179 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:13,179 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:14,424 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:14,425 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:15,606 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:15,606 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:16,934 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:16,934 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:18,134 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:18,134 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:19,383 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:19,383 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:20,639 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:20,639 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:21,809 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:08:21,809 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:08:21,810 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 17:18:14,994 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-04 17:20:39,388 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:39,388 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:40,562 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:40,563 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:41,738 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:41,738 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:43,017 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:43,017 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:44,275 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:44,275 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:45,548 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:45,548 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:46,743 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:46,743 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:47,987 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:47,987 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:49,183 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:49,183 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:50,393 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:50,394 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:51,724 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:51,724 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:52,901 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:52,901 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:54,161 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:54,161 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:55,332 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:55,333 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:56,561 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-04 17:20:56,561 main.py[line:110] - ERROR - 处理失败 +2024-07-04 17:20:56,561 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-05 14:23:17,274 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-05 14:52:48,462 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-05 14:59:25,432 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-05 14:59:25,433 main.py[line:110] - ERROR - 处理失败 +2024-07-05 14:59:25,433 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-05 15:21:42,677 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-07 16:11:16,751 pipe_utils.py[line:231] - ERROR - 发送指令失败,错误类型:(232, 'WriteFile', '管道正在被关闭。') +2024-07-07 16:11:16,752 main.py[line:125] - ERROR - 处理失败 +2024-07-07 16:11:16,752 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-07 16:25:38,533 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') +2024-07-07 16:34:38,764 pipe_utils.py[line:85] - ERROR - 数据接收失败,错误原因: (109, 'ReadFile', '管道已结束。') diff --git a/20240627Actual_deployed/totest.py b/20240627Actual_deployed/totest.py new file mode 100644 index 0000000..fba8382 --- /dev/null +++ b/20240627Actual_deployed/totest.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# @Time : 2024/7/7 下午4:33 +# @Author : TG +# @File : totest.py +# @Software: PyCharm +import time + +from detector import Detector_to +import numpy as np + +import os +from PIL import Image + + + + +def main(): + s = [] + path = r'D:\project\20240627Actual_deployed\to' + to = Detector_to() + i = 1 + for filename in os.listdir(path): + if filename.endswith('.bmp'): + img_path = os.path.join(path, filename) + image = Image.open(img_path) + img = np.array(image) + t = time.time() + result = to.run(img) + e = time.time() + print(f'第{i}张图时间:{e-t}') + print(f'图片名:{filename},结果:{result}') + s.append(result) + i += 1 + print(f'长度:{sum(s)}') + + +#0为褶皱,1为正常 + + +if __name__ == '__main__': + ''' + python与qt采用windows下的命名管道进行通信,数据流按照约定的通信协议进行 + 数据处理逻辑为:连续接收5张RGB图,然后根据解析出的指令部分决定是否接收一张光谱图,然后进行处理,最后将处理得到的指标结果进行编码回传 + ''' + main() \ No newline at end of file diff --git a/20240627Actual_deployed/utils/torch_utils.py b/20240627Actual_deployed/utils/torch_utils.py index d15f1f7..242f638 100644 --- a/20240627Actual_deployed/utils/torch_utils.py +++ b/20240627Actual_deployed/utils/torch_utils.py @@ -144,7 +144,7 @@ def select_device(device="", batch_size=0, newline=True): if not newline: s = s.rstrip() - LOGGER.info(s) + # LOGGER.info(s) return torch.device(arg) @@ -322,7 +322,7 @@ def model_info(model, verbose=False, imgsz=640): fs = "" name = Path(model.yaml_file).stem.replace("yolov5", "YOLOv5") if hasattr(model, "yaml_file") else "Model" - LOGGER.info(f"{name} summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}") + # LOGGER.info(f"{name} summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}") def scale_img(img, ratio=1.0, same_shape=False, gs=32): # img(16,3,256,416) diff --git a/classfier.py b/classfier.py deleted file mode 100644 index 2d476fc..0000000 --- a/classfier.py +++ /dev/null @@ -1,165 +0,0 @@ -import logging -import sys -from typing import Optional - -import numpy as np -import cv2 -from sklearn.tree import DecisionTreeClassifier -from sklearn.cluster import KMeans -from sklearn.linear_model import LogisticRegression -from sklearn.model_selection import train_test_split -from sklearn.metrics import accuracy_score, confusion_matrix -from scipy import ndimage -from sklearn.tree import DecisionTreeClassifier -from sklearn.feature_selection import SelectKBest -from sklearn.neighbors import KNeighborsClassifier -from scipy.stats import binom -import matplotlib.pyplot as plt -import time -import pickle -import os -import utils -from root_dir import ROOT_DIR - - -class Astragalin(object): - def __init__(self, load_from=None, debug_mode=False, class_weight=None): - if load_from is None: - self.model = DecisionTreeClassifier(random_state=65, class_weight=class_weight) - else: - self.load(load_from) - self.log = utils.Logger(is_to_file=debug_mode) - self.debug_mode = debug_mode - - def load(self, path=None): - if path is None: - path = os.path.join(ROOT_DIR, 'models') - model_files = os.listdir(path) - if len(model_files) == 0: - self.log.log("No model found!") - return 1 - self.log.log("./ Models Found:") - _ = [self.log.log("├--" + str(model_file)) for model_file in model_files] - file_times = [model_file[6:-2] for model_file in model_files] - latest_model = model_files[int(np.argmax(file_times))] - self.log.log("└--Using the latest model: " + str(latest_model)) - path = os.path.join(ROOT_DIR, "models", str(latest_model)) - if not os.path.isabs(path): - logging.warning('给的是相对路径') - return -1 - if not os.path.exists(path): - logging.warning('文件不存在') - return -1 - with open(path, 'rb') as f: - model_dic = pickle.load(f) - self.model = model_dic['model'] - return 0 - - def fit(self, data_x, data_y): - x_train, x_test, y_train, y_test = train_test_split(data_x, data_y, test_size=0.3, random_state=65) - self.model.fit(x_train, y_train) - y_pred = self.model.predict(x_test) - print(confusion_matrix(y_test, y_pred)) - - pre_score = accuracy_score(y_test, y_pred) - self.log.log("Test accuracy is:" + str(pre_score * 100) + "%.") - y_pred = self.model.predict(x_train) - - pre_score = accuracy_score(y_train, y_pred) - self.log.log("Train accuracy is:" + str(pre_score * 100) + "%.") - y_pred = self.model.predict(data_x) - - pre_score = accuracy_score(data_y, y_pred) - self.log.log("Total accuracy is:" + str(pre_score * 100) + "%.") - - return int(pre_score * 100) - - def fit_value(self, file_name=None, data_path='data/1.txt', select_bands=[91, 92, 93, 94, 95, 96, 97, 98, 99, 100]): - data_x, data_y = self.data_construction(data_path, select_bands) - score = self.fit(data_x, data_y) - print('score:', score) - model_name = self.save(file_name=file_name) - return score, model_name - - def save(self, file_name): - # 保存模型 - if file_name is None: - file_name = "model_" + time.strftime("%Y-%m-%d_%H-%M") + ".p" - file_name = os.path.join(ROOT_DIR, "models", file_name) - model_dic = {'model': self.model} - with open(file_name, 'wb') as f: - pickle.dump(model_dic, f) - self.log.log("Model saved to '" + str(file_name) + "'.") - return file_name - - # def data_construction(self, data_path, select_bands): - # data = utils.read_envi_ascii(data_path) - # beijing = data['beijing'][:, select_bands] - # zazhi1 = data['zazhi1'][:, select_bands] - # # zazhi2 = data['zazhi2'][:, select_bands] - # huangqi = data['huangqi'][:, select_bands] - # gancaopian = data['gancaopian'][:, select_bands] - # # hongqi = data['hongqi'][:, select_bands] - # beijing_y = np.zeros(beijing.shape[0]) - # zazhi1_y = np.ones(zazhi1.shape[0]) * 3 - # # zazhi2_y = np.ones(zazhi2.shape[0]) * 2 - # huangqi_y = np.ones(huangqi.shape[0]) * 1 - # gancaopian_y = np.ones(gancaopian.shape[0]) * 4 - # # hongqi_y = np.ones(hongqi.shape[0]) * 5 - # data_x = np.concatenate((beijing, zazhi1, huangqi, gancaopian), axis=0) - # data_y = np.concatenate((beijing_y, zazhi1_y, huangqi_y, gancaopian_y), axis=0) - # return data_x, data_y - - def data_construction(self, data_path='data/1.txt', select_bands=[91, 92, 93, 94, 95, 96, 97, 98, 99, 100], - type=['beijing', 'zazhi1', 'huangqi', 'gancaopian']): - ''' - :param data_path: 数据文件路径 - :param select_bands: 选择的波段 - :param type: 选择的类型 - :return: data_x, data_y - ''' - data = utils.read_envi_ascii(data_path) - # 判断读取的txt文件内是否有beijing和haungqi类型的数据 - if 'beijing' not in data or 'huangqi' not in data: - logging.error("数据文件中缺少'beijing'或'huangqi'类型标签") - raise ValueError("数据文件中缺少'beijing'或'huangqi'类型标签") - data_x = np.concatenate([data[key][:, select_bands] for key in type], axis=0) - data_y = np.concatenate([np.zeros(data[key].shape[0]) if key == 'beijing' else np.ones(data[key].shape[0]) - if key == 'huangqi' else np.ones(data[key].shape[0]) * (i + 2) for i, key in enumerate(type)], axis=0) - return data_x, data_y - - def predict(self, data_x): - ''' - 对数据进行预测 - :param data_x: 波段选择后的数据 - :return: 预测结果二值化后的数据,0为背景,1为黄芪,2为杂质2,3为杂质1,4为甘草片,5为红芪 - ''' - data_x_shape = data_x.shape - data_x = data_x.reshape(-1, data_x.shape[2]) - data_y = self.model.predict(data_x) - data_y = data_y.reshape(data_x_shape[0], data_x_shape[1]).astype(np.uint8) - data_y, centers, categories = self.connect_space(data_y) - result = {'data_y': data_y, 'centers': centers, 'categories': categories} - return result - - def connect_space(self, data_y): - # 连通域处理离散点 - labels, num_features = ndimage.label(data_y) - centers = [] - categories = [] - for i in range(1, num_features + 1): - mask = (labels == i) - counts = np.bincount(data_y[mask]) - category = np.argmax(counts) - data_y[mask] = category - center = ndimage.measurements.center_of_mass(data_y, labels, [i]) - center = list(center) - center = np.array(center).astype(int) - centers.append(center) - categories.append(category) - return data_y, centers, categories - - -if __name__ == '__main__': - detector = Astragalin() - detector.fit_value(file_name="astragalin.p", data_path="data/1.txt") \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 090ae06..0000000 --- a/main.py +++ /dev/null @@ -1,197 +0,0 @@ - -import socket -import time - -import numpy as np -import logging -import os -import sys -import cv2 as cv - -from classfier import Astragalin -from utils import DualSock, try_connect, receive_sock, parse_protocol, ack_sock, done_sock -from root_dir import ROOT_DIR -from model import resnet34 -import torch -from torchvision import transforms -from PIL import Image -import json -import matplotlib.pyplot as plt -from PIL import Image - - - -def process_cmd(cmd: str, data: any, connected_sock: socket.socket) -> tuple: - ''' - 处理指令 - :param cmd: 指令类型 - :param data: 指令内容 - :param connected_sock: socket - :param detector: 模型 - :return: 是否处理成功 - ''' - result = '' - if cmd == 'IM': - data = np.frombuffer(data, dtype=np.uint8) - data = cv.imdecode(data, cv.IMREAD_COLOR) - - # 显示图片 - cv.imshow('image', data) - cv.waitKey(0) - cv.destroyAllWindows() - - # device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") - # - # data_transform = transforms.Compose( - # [transforms.Resize(256), - # transforms.CenterCrop(224), - # transforms.ToTensor(), - # transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]) - # - # # load image - # # img_path = r"D:\project\deep-learning-for-image-processing-master\data_set\test_image\1.jpg" - # # assert os.path.exists(img_path), "file: '{}' dose not exist.".format(img_path) - # # img = Image.open(img_path) - # # plt.imshow(img) - # # [N, C, H, W] - # img = data_transform(data) - # # expand batch dimension - # img = torch.unsqueeze(img, dim=0) - # - # # read class_indict - # # json_path = './class_indices.json' - # # assert os.path.exists(json_path), "file: '{}' dose not exist.".format(json_path) - # # - # # with open(json_path, "r") as f: - # # class_indict = json.load(f) - # - # # create model - # model = resnet34(num_classes=4).to(device) - # - # # load model weights - # weights_path = r"D:\project\deep-learning-for-image-processing-master\pytorch_classification\Test5_resnet\resNet34.pth" - # assert os.path.exists(weights_path), "file: '{}' dose not exist.".format(weights_path) - # model.load_state_dict(torch.load(weights_path, map_location=device)) - # - # # prediction - # model.eval() - # with torch.no_grad(): - # # predict class - # output = torch.squeeze(model(img.to(device))).cpu() - # predict = torch.softmax(output, dim=0) - # predict_cla = torch.argmax(predict).numpy() - # result = predict_cla - # print(predict_cla) - # print_res = "class: {} prob: {:.3}".format(class_indict[str(predict_cla)], - # predict[predict_cla].numpy()) - # plt.title(print_res) - # for i in range(len(predict)): - # print("class: {:10} prob: {:.3}".format(class_indict[str(i)], - # predict[i].numpy())) - # plt.show() - - - # result = detector.predict(data) - # # 取出result中的字典中的centers和categories - # centers = result['centers'] - # categories = result['categories'] - # # 将centers和categories转换为字符串,每一位之间用,隔开,centers是list,每个元素为np.array,categories是1维数组 - # # centers_str = '|'.join([str(point[0][0]) + ',' + str(point[0][1]) for point in centers]) - # # categories_str = ','.join([str(i) for i in categories]) - # # # 将centers和categories的字符串拼接起来,中间用;隔开 - # # result = centers_str + ';' + categories_str - # 给result直接赋值,用于测试 - # result = 'HELLO WORLD' - # response = done_sock(connected_sock, cmd_type=cmd, result=result) - # print(result) - else: - logging.error(f'错误指令,指令为{cmd}') - # response = False - return result - -def bytes_to_img(data): - data1 = Image.frombytes('RGB', (1200, 4096), data, 'raw') - - - - - -# def main(is_debug=False): -# file_handler = logging.FileHandler(os.path.join(ROOT_DIR, 'report.log')) -# file_handler.setLevel(logging.DEBUG if is_debug else logging.WARNING) -# console_handler = logging.StreamHandler(sys.stdout) -# console_handler.setLevel(logging.DEBUG if is_debug else logging.WARNING) -# logging.basicConfig(format='%(asctime)s %(filename)s[line:%(lineno)d] - %(levelname)s - %(message)s', -# handlers=[file_handler, console_handler], level=logging.DEBUG) -# dual_sock = DualSock(connect_ip='127.0.0.1') -# -# while not dual_sock.status: -# logging.error('连接被断开,正在重连') -# dual_sock.reconnect() -# detector = Astragalin(ROOT_DIR / 'models' / 'astragalin.p') -# # _ = detector.predict(np.ones((4096, 1200, 10), dtype=np.float32)) -# while True: -# pack, next_pack = receive_sock(dual_sock) # 接收数据,如果没有数据则阻塞,如果返回的是空字符串则表示出现错误 -# if pack == b"": # 无数据表示出现错误 -# time.sleep(5) -# dual_sock.reconnect() -# continue -# -# cmd, data = parse_protocol(pack) -# print(cmd) -# # print(data) -# -# process_cmd(cmd=cmd, data=data, connected_sock=dual_sock, detector=detector) - - -def main(is_debug=False): - file_handler = logging.FileHandler(os.path.join(ROOT_DIR, 'report.log')) - file_handler.setLevel(logging.DEBUG if is_debug else logging.WARNING) - console_handler = logging.StreamHandler(sys.stdout) - console_handler.setLevel(logging.DEBUG if is_debug else logging.WARNING) - logging.basicConfig(format='%(asctime)s %(filename)s[line:%(lineno)d] - %(levelname)s - %(message)s', - handlers=[file_handler, console_handler], level=logging.DEBUG) - dual_sock = DualSock(connect_ip='127.0.0.1') - - while not dual_sock.status: - logging.error('连接被断开,正在重连') - dual_sock.reconnect() - - - - # detector = Astragalin(ROOT_DIR / 'models' / 'resNet34.pth') - result_buffer = [] # 存储处理结果的缓冲区 - - while True: - for _ in range(5): - pack, next_pack = receive_sock(dual_sock) # 接收数据,如果没有数据则阻塞,如果返回的是空字符串则表示出现错误 - if pack == b"": # 无数据表示出现错误 - time.sleep(5) - dual_sock.reconnect() - break - - cmd, data = parse_protocol(pack) - print(cmd) - # print(data) - - result = process_cmd(cmd=cmd, data=data, connected_sock=dual_sock) - result_buffer.append(result) # 将处理结果添加到缓冲区 - - # 在这里进行对5次结果的处理,可以进行合并、比较等操作 - final_result = combine_results(result_buffer) - - # 发送最终结果 - response = done_sock(dual_sock, cmd_type=cmd, result=final_result) - print(final_result) - result_buffer = [] - - - -def combine_results(results): - # 在这里实现对5次结果的合并/比较等操作,根据实际需求进行修改 - # 这里只是简单地将结果拼接成一个字符串,你可能需要根据实际情况进行更复杂的处理 - return ';'.join(results) - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/model.py b/model.py deleted file mode 100644 index c2aa086..0000000 --- a/model.py +++ /dev/null @@ -1,198 +0,0 @@ -import torch.nn as nn -import torch - - -class BasicBlock(nn.Module): - expansion = 1 - - def __init__(self, in_channel, out_channel, stride=1, downsample=None, **kwargs): - super(BasicBlock, self).__init__() - self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel, - kernel_size=3, stride=stride, padding=1, bias=False) - self.bn1 = nn.BatchNorm2d(out_channel) - self.relu = nn.ReLU() - self.conv2 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel, - kernel_size=3, stride=1, padding=1, bias=False) - self.bn2 = nn.BatchNorm2d(out_channel) - self.downsample = downsample - - def forward(self, x): - identity = x - if self.downsample is not None: - identity = self.downsample(x) - - out = self.conv1(x) - out = self.bn1(out) - out = self.relu(out) - - out = self.conv2(out) - out = self.bn2(out) - - out += identity - out = self.relu(out) - - return out - - -class Bottleneck(nn.Module): - """ - 注意:原论文中,在虚线残差结构的主分支上,第一个1x1卷积层的步距是2,第二个3x3卷积层步距是1。 - 但在pytorch官方实现过程中是第一个1x1卷积层的步距是1,第二个3x3卷积层步距是2, - 这么做的好处是能够在top1上提升大概0.5%的准确率。 - 可参考Resnet v1.5 https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch - """ - expansion = 4 - - def __init__(self, in_channel, out_channel, stride=1, downsample=None, - groups=1, width_per_group=64): - super(Bottleneck, self).__init__() - - width = int(out_channel * (width_per_group / 64.)) * groups - - self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=width, - kernel_size=1, stride=1, bias=False) # squeeze channels - self.bn1 = nn.BatchNorm2d(width) - # ----------------------------------------- - self.conv2 = nn.Conv2d(in_channels=width, out_channels=width, groups=groups, - kernel_size=3, stride=stride, bias=False, padding=1) - self.bn2 = nn.BatchNorm2d(width) - # ----------------------------------------- - self.conv3 = nn.Conv2d(in_channels=width, out_channels=out_channel*self.expansion, - kernel_size=1, stride=1, bias=False) # unsqueeze channels - self.bn3 = nn.BatchNorm2d(out_channel*self.expansion) - self.relu = nn.ReLU(inplace=True) - self.downsample = downsample - - def forward(self, x): - identity = x - if self.downsample is not None: - identity = self.downsample(x) - - out = self.conv1(x) - out = self.bn1(out) - out = self.relu(out) - - out = self.conv2(out) - out = self.bn2(out) - out = self.relu(out) - - out = self.conv3(out) - out = self.bn3(out) - - out += identity - out = self.relu(out) - - return out - - -class ResNet(nn.Module): - - def __init__(self, - block, - blocks_num, - num_classes=1000, - include_top=True, - groups=1, - width_per_group=64): - super(ResNet, self).__init__() - self.include_top = include_top - self.in_channel = 64 - - self.groups = groups - self.width_per_group = width_per_group - - self.conv1 = nn.Conv2d(3, self.in_channel, kernel_size=7, stride=2, - padding=3, bias=False) - self.bn1 = nn.BatchNorm2d(self.in_channel) - self.relu = nn.ReLU(inplace=True) - self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) - self.layer1 = self._make_layer(block, 64, blocks_num[0]) - self.layer2 = self._make_layer(block, 128, blocks_num[1], stride=2) - self.layer3 = self._make_layer(block, 256, blocks_num[2], stride=2) - self.layer4 = self._make_layer(block, 512, blocks_num[3], stride=2) - if self.include_top: - self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) # output size = (1, 1) - self.fc = nn.Linear(512 * block.expansion, num_classes) - - for m in self.modules(): - if isinstance(m, nn.Conv2d): - nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') - - def _make_layer(self, block, channel, block_num, stride=1): - downsample = None - if stride != 1 or self.in_channel != channel * block.expansion: - downsample = nn.Sequential( - nn.Conv2d(self.in_channel, channel * block.expansion, kernel_size=1, stride=stride, bias=False), - nn.BatchNorm2d(channel * block.expansion)) - - layers = [] - layers.append(block(self.in_channel, - channel, - downsample=downsample, - stride=stride, - groups=self.groups, - width_per_group=self.width_per_group)) - self.in_channel = channel * block.expansion - - for _ in range(1, block_num): - layers.append(block(self.in_channel, - channel, - groups=self.groups, - width_per_group=self.width_per_group)) - - return nn.Sequential(*layers) - - def forward(self, x): - x = self.conv1(x) - x = self.bn1(x) - x = self.relu(x) - x = self.maxpool(x) - - x = self.layer1(x) - x = self.layer2(x) - x = self.layer3(x) - x = self.layer4(x) - - if self.include_top: - x = self.avgpool(x) - x = torch.flatten(x, 1) - x = self.fc(x) - - return x - - -def resnet34(num_classes=1000, include_top=True): - # https://download.pytorch.org/models/resnet34-333f7ec4.pth - return ResNet(BasicBlock, [3, 4, 6, 3], num_classes=num_classes, include_top=include_top) - - -def resnet50(num_classes=1000, include_top=True): - # https://download.pytorch.org/models/resnet50-19c8e357.pth - return ResNet(Bottleneck, [3, 4, 6, 3], num_classes=num_classes, include_top=include_top) - - -def resnet101(num_classes=1000, include_top=True): - # https://download.pytorch.org/models/resnet101-5d3b4d8f.pth - return ResNet(Bottleneck, [3, 4, 23, 3], num_classes=num_classes, include_top=include_top) - - -def resnext50_32x4d(num_classes=1000, include_top=True): - # https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pth - groups = 32 - width_per_group = 4 - return ResNet(Bottleneck, [3, 4, 6, 3], - num_classes=num_classes, - include_top=include_top, - groups=groups, - width_per_group=width_per_group) - - -def resnext101_32x8d(num_classes=1000, include_top=True): - # https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pth - groups = 32 - width_per_group = 8 - return ResNet(Bottleneck, [3, 4, 23, 3], - num_classes=num_classes, - include_top=include_top, - groups=groups, - width_per_group=width_per_group) diff --git a/models/12.p b/models/12.p deleted file mode 100644 index c876b0e..0000000 Binary files a/models/12.p and /dev/null differ diff --git a/models/astragalin.p b/models/astragalin.p deleted file mode 100644 index 4428ca7..0000000 Binary files a/models/astragalin.p and /dev/null differ diff --git a/models/dt.p b/models/dt.p deleted file mode 100644 index a2fd313..0000000 Binary files a/models/dt.p and /dev/null differ diff --git a/models/resNet34.pth b/models/resNet34.pth deleted file mode 100644 index 45154d6..0000000 Binary files a/models/resNet34.pth and /dev/null differ diff --git a/qt_test.py b/qt_test.py deleted file mode 100644 index b72f5a5..0000000 --- a/qt_test.py +++ /dev/null @@ -1,167 +0,0 @@ - -import numpy as np -import socket -import logging -import matplotlib.pyplot as plt -import cv2 - -def rec_socket(recv_sock: socket.socket, cmd_type: str, ack: bool) -> bool: - if ack: - cmd = 'A' + cmd_type - else: - cmd = 'D' + cmd_type - while True: - try: - temp = recv_sock.recv(1) - except ConnectionError as e: - logging.error(f'连接出错, 错误代码:\n{e}') - return False - except TimeoutError as e: - logging.error(f'超时了,错误代码: \n{e}') - return False - except Exception as e: - logging.error(f'遇见未知错误,错误代码: \n{e}') - return False - if temp == b'\xaa': - break - - # 获取报文长度 - temp = b'' - while len(temp) < 4: - try: - temp += recv_sock.recv(1) - except Exception as e: - logging.error(f'接收报文长度失败, 错误代码: \n{e}') - return False - try: - data_len = int.from_bytes(temp, byteorder='big') - except Exception as e: - logging.error(f'转换失败,错误代码 \n{e}, \n报文内容\n{temp}') - return False - - # 读取报文内容 - temp = b'' - while len(temp) < data_len: - try: - temp += recv_sock.recv(data_len) - except Exception as e: - logging.error(f'接收报文内容失败, 错误代码: \n{e},\n报文内容\n{temp}') - return False - data = temp - if cmd.strip().upper() != data[:4].decode('ascii').strip().upper(): - logging.error(f'客户端接收指令错误,\n指令内容\n{data}') - return False - else: - if cmd == 'DIM': - print(data) - - # 进行数据校验 - temp = b'' - while len(temp) < 3: - try: - temp += recv_sock.recv(1) - except Exception as e: - logging.error(f'接收报文校验失败, 错误代码: \n{e}') - return False - if temp == b'\xff\xff\xbb': - return True - else: - logging.error(f"接收了一个完美的只错了校验位的报文,\n data: {data}") - return False - - -# def main(): -# socket_receive = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -# socket_receive.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) -# socket_receive.bind(('127.0.0.1', 21123)) -# socket_receive.listen(5) -# socket_send = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -# socket_send.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) -# socket_send.bind(('127.0.0.1', 21122)) -# socket_send.listen(5) -# print('等待连接') -# socket_send_1, receive_addr_1 = socket_send.accept() -# print("连接成功:", receive_addr_1) -# # socket_send_2 = socket_send_1 -# socket_send_2, receive_addr_2 = socket_receive.accept() -# print("连接成功:", receive_addr_2) -# while True: -# cmd = input('请输入指令:').strip().upper() -# if cmd == 'IM': -# with open('data/newrawfile_ref.raw', 'rb') as f: -# data = np.frombuffer(f.read(), dtype=np.float32).reshape(750, 288, 384) -# data = data[:, [91, 92, 93, 94, 95, 96, 97, 98, 99, 100], :] -# n_rows, n_bands, n_cols = data.shape[0], data.shape[1], data.shape[2] -# print(f'n_rows:{n_rows}, n_bands:{n_bands}, n_cols:{n_cols}') -# n_rows, n_cols, n_bands = [x.to_bytes(2, byteorder='big') for x in [n_rows, n_cols, n_bands]] -# data = data.tobytes() -# length = len(data) + 10 -# print(f'length: {length}') -# length = length.to_bytes(4, byteorder='big') -# msg = b'\xaa' + length + (' ' + cmd).upper().encode('ascii') + n_rows + n_cols + n_bands + data + b'\xff\xff\xbb' -# socket_send_1.send(msg) -# print('发送成功') -# result = socket_send_2.recv(5) -# length = int.from_bytes(result[1:5], byteorder='big') -# result = b'' -# while len(result) < length: -# result += socket_send_2.recv(length) -# print(result) -# data = result[4:length].decode() -# print(data) - -def main(): - socket_receive = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - socket_receive.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - socket_receive.bind(('127.0.0.1', 21123)) - socket_receive.listen(5) - socket_send = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - socket_send.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - socket_send.bind(('127.0.0.1', 21122)) - socket_send.listen(5) - print('等待连接') - socket_send_1, receive_addr_1 = socket_send.accept() - print("连接成功:", receive_addr_1) - # socket_send_2 = socket_send_1 - socket_send_2, receive_addr_2 = socket_receive.accept() - print("连接成功:", receive_addr_2) - while True: - cmd = input().strip().upper() - if cmd == 'IM': - - image_paths = [ - r"D:\project\deep-learning-for-image-processing-master\data_set\test_image\1.jpg", - r"D:\project\deep-learning-for-image-processing-master\data_set\test_image\2.jpg", - r"D:\project\deep-learning-for-image-processing-master\data_set\test_image\3.jpg", - r"D:\project\deep-learning-for-image-processing-master\data_set\test_image\4.jpg", - r"D:\project\deep-learning-for-image-processing-master\data_set\test_image\5.jpg", - ] - - # 连续发送五张图片 - for image_path in image_paths: - # 读取图片文件 - img = cv2.imread(image_path) - - # img = cv2.imread(r"/Users/zhouchao/Library/CloudStorage/OneDrive-macrosolid/PycharmProjects/wood_color/data/data20220919/dark/rgb60.png") - # img = cv2.imread(r"D:\project\Astragalin\data\02newrawfile_ref.png") - img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) - img = np.asarray(img, dtype=np.uint8) - width = img.shape[0] - height = img.shape[1] - print(width, height) - img_bytes = img.tobytes() - length = len(img_bytes) + 8 - print(length) - length = length.to_bytes(4, byteorder='big') - width = width.to_bytes(2, byteorder='big') - height = height.to_bytes(2, byteorder='big') - send_message = b'\xaa' + length + (' ' + cmd).upper().encode('ascii') + width + height + img_bytes + b'\xff\xff\xbb' - socket_send_1.send(send_message) - print('发送成功') - result = socket_send_2.recv(10) - print(result) - - - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 5db72dd..0000000 --- a/renovate.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:recommended" - ] -} diff --git a/report.log b/report.log deleted file mode 100644 index fbb5a0d..0000000 --- a/report.log +++ /dev/null @@ -1,840 +0,0 @@ -2024-01-15 14:32:13,594 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 14:32:18,595 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-01-15 14:32:38,650 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 14:32:38,651 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-15 14:32:38,651 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 14:32:38,661 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-15 15:33:19,091 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 15:33:19,592 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-15 15:33:19,592 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 15:33:19,602 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-15 15:56:26,748 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 15:56:26,749 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10065] �׽��ֲ�������һ���޷����ӵ������� -2024-01-15 15:56:31,750 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-15 15:56:31,750 utils.py[line:224] - ERROR - ��2������ʧ��... 5�����������... - [WinError 10065] �׽��ֲ�������һ���޷����ӵ������� -2024-01-15 15:56:36,750 utils.py[line:218] - WARNING - ���Է����3������... -2024-01-15 15:56:36,750 utils.py[line:224] - ERROR - ��3������ʧ��... 5�����������... - [WinError 10065] �׽��ֲ�������һ���޷����ӵ������� -2024-01-15 15:56:41,751 utils.py[line:218] - WARNING - ���Է����4������... -2024-01-15 15:56:41,762 utils.py[line:224] - ERROR - ��4������ʧ��... 5�����������... - [WinError 10065] �׽��ֲ�������һ���޷����ӵ������� -2024-01-15 15:58:41,933 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 15:58:41,933 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10065] �׽��ֲ�������һ���޷����ӵ������� -2024-01-15 15:58:58,774 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 15:59:00,778 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-15 15:59:05,778 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-15 15:59:07,791 utils.py[line:224] - ERROR - ��2������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-15 15:59:12,791 utils.py[line:218] - WARNING - ���Է����3������... -2024-01-15 15:59:14,804 utils.py[line:224] - ERROR - ��3������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-15 15:59:58,488 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 15:59:58,488 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10065] �׽��ֲ�������һ���޷����ӵ������� -2024-01-15 16:00:33,001 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-15 16:00:38,003 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-01-15 16:00:43,004 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-23 09:25:24,555 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:25:29,584 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-01-23 09:25:34,584 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-23 09:25:39,584 utils.py[line:224] - ERROR - ��2������ʧ��... 5�����������... - timed out -2024-01-23 09:25:44,584 utils.py[line:218] - WARNING - ���Է����3������... -2024-01-23 09:25:49,585 utils.py[line:224] - ERROR - ��3������ʧ��... 5�����������... - timed out -2024-01-23 09:25:54,585 utils.py[line:218] - WARNING - ���Է����4������... -2024-01-23 09:25:59,585 utils.py[line:224] - ERROR - ��4������ʧ��... 5�����������... - timed out -2024-01-23 09:26:04,586 utils.py[line:218] - WARNING - ���Է����5������... -2024-01-23 09:26:09,587 utils.py[line:224] - ERROR - ��5������ʧ��... 5�����������... - timed out -2024-01-23 09:26:14,587 utils.py[line:218] - WARNING - ���Է����6������... -2024-01-23 09:38:11,783 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:38:13,823 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 09:38:39,301 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:38:44,302 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-01-23 09:38:49,302 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-23 09:38:54,304 utils.py[line:224] - ERROR - ��2������ʧ��... 5�����������... - timed out -2024-01-23 09:39:01,468 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:39:06,469 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-01-23 09:39:11,469 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-23 09:39:16,470 utils.py[line:224] - ERROR - ��2������ʧ��... 5�����������... - timed out -2024-01-23 09:39:21,470 utils.py[line:218] - WARNING - ���Է����3������... -2024-01-23 09:39:26,471 utils.py[line:224] - ERROR - ��3������ʧ��... 5�����������... - timed out -2024-01-23 09:39:31,471 utils.py[line:218] - WARNING - ���Է����4������... -2024-01-23 09:39:36,473 utils.py[line:224] - ERROR - ��4������ʧ��... 5�����������... - timed out -2024-01-23 09:39:41,473 utils.py[line:218] - WARNING - ���Է����5������... -2024-01-23 09:39:46,473 utils.py[line:224] - ERROR - ��5������ʧ��... 5�����������... - timed out -2024-01-23 09:39:51,474 utils.py[line:218] - WARNING - ���Է����6������... -2024-01-23 09:40:20,420 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:40:20,420 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 09:40:20,421 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:40:20,431 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 09:42:30,429 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:42:35,431 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-01-23 09:42:40,431 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-23 09:42:49,844 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 09:42:54,845 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-01-23 09:42:59,846 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-23 09:43:04,846 utils.py[line:224] - ERROR - ��2������ʧ��... 5�����������... - timed out -2024-01-23 09:43:09,847 utils.py[line:218] - WARNING - ���Է����3������... -2024-01-23 09:43:14,848 utils.py[line:224] - ERROR - ��3������ʧ��... 5�����������... - timed out -2024-01-23 09:43:19,848 utils.py[line:218] - WARNING - ���Է����4������... -2024-01-23 09:43:21,562 utils.py[line:224] - ERROR - ��4������ʧ��... 5�����������... - [WinError 10053] ��������е������ֹ��һ���ѽ��������ӡ� -2024-01-23 09:43:26,563 utils.py[line:218] - WARNING - ���Է����5������... -2024-01-23 09:43:31,564 utils.py[line:224] - ERROR - ��5������ʧ��... 5�����������... - timed out -2024-01-23 09:43:36,564 utils.py[line:218] - WARNING - ���Է����6������... -2024-01-23 09:43:41,564 utils.py[line:224] - ERROR - ��6������ʧ��... 5�����������... - timed out -2024-01-23 09:43:46,565 utils.py[line:218] - WARNING - ���Է����7������... -2024-01-23 15:10:24,801 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 15:10:24,840 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 15:10:24,840 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 15:10:24,850 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 15:10:49,904 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 15:10:49,907 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 15:10:49,908 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 15:10:49,908 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 15:10:50,025 utils.py[line:296] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-01-23 18:15:41,050 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 18:15:41,061 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 18:15:41,061 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 18:15:41,073 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 18:17:09,557 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 18:17:10,099 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 18:17:10,099 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 18:17:10,099 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 18:19:41,713 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 18:19:41,718 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 18:19:41,719 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 18:19:41,720 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:02:21,402 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:02:21,471 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:02:21,472 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:02:21,472 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:15:31,925 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:15:31,926 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:15:31,926 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:15:31,936 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:16:44,610 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:16:44,611 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:16:44,611 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:16:44,612 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:17:28,898 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:17:28,898 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:17:28,899 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:17:28,899 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:21:07,938 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:21:09,943 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:21:14,943 utils.py[line:218] - WARNING - ���Է����2������... -2024-01-23 20:21:16,959 utils.py[line:224] - ERROR - ��2������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:21:21,959 utils.py[line:218] - WARNING - ���Է����3������... -2024-01-23 20:21:23,961 utils.py[line:224] - ERROR - ��3������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:21:28,962 utils.py[line:218] - WARNING - ���Է����4������... -2024-01-23 20:21:30,967 utils.py[line:224] - ERROR - ��4������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:21:35,967 utils.py[line:218] - WARNING - ���Է����5������... -2024-01-23 20:21:37,979 utils.py[line:224] - ERROR - ��5������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:21:42,980 utils.py[line:218] - WARNING - ���Է����6������... -2024-01-23 20:21:44,993 utils.py[line:224] - ERROR - ��6������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:21:49,993 utils.py[line:218] - WARNING - ���Է����7������... -2024-01-23 20:21:52,006 utils.py[line:224] - ERROR - ��7������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:21:57,006 utils.py[line:218] - WARNING - ���Է����8������... -2024-01-23 20:21:59,009 utils.py[line:224] - ERROR - ��8������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:22:04,010 utils.py[line:218] - WARNING - ���Է����9������... -2024-01-23 20:22:06,014 utils.py[line:224] - ERROR - ��9������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:22:11,015 utils.py[line:218] - WARNING - ���Է����10������... -2024-01-23 20:22:13,018 utils.py[line:224] - ERROR - ��10������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:22:18,019 utils.py[line:218] - WARNING - ���Է����11������... -2024-01-23 20:22:20,022 utils.py[line:224] - ERROR - ��11������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:22:25,023 utils.py[line:218] - WARNING - ���Է����12������... -2024-01-23 20:22:27,035 utils.py[line:224] - ERROR - ��12������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:22:32,036 utils.py[line:218] - WARNING - ���Է����13������... -2024-01-23 20:22:34,051 utils.py[line:224] - ERROR - ��13������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-01-23 20:22:49,248 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:22:49,248 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:22:49,248 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:22:49,259 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:24:03,935 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:24:03,936 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:24:03,936 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:24:03,947 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:27:46,805 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:27:46,806 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:27:46,806 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:27:46,817 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:30:26,366 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:30:26,367 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-23 20:30:26,367 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-23 20:30:26,377 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-24 09:59:18,581 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-24 09:59:18,613 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-24 09:59:18,613 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-24 09:59:18,614 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-24 10:01:30,602 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-24 10:01:30,603 utils.py[line:227] - WARNING - ���ӳɹ� -2024-01-24 10:01:30,603 utils.py[line:218] - WARNING - ���Է����1������... -2024-01-24 10:01:30,614 utils.py[line:227] - WARNING - ���ӳɹ� -2024-04-12 16:00:15,521 utils.py[line:218] - WARNING - ���Է����1������... -2024-04-12 16:00:15,550 utils.py[line:227] - WARNING - ���ӳɹ� -2024-04-12 16:00:15,551 utils.py[line:218] - WARNING - ���Է����1������... -2024-04-12 16:00:15,551 utils.py[line:227] - WARNING - ���ӳɹ� -2024-04-12 16:00:15,633 utils.py[line:296] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 16:00:20,635 utils.py[line:218] - WARNING - ���Է����1������... -2024-04-12 16:00:20,645 utils.py[line:227] - WARNING - ���ӳɹ� -2024-04-12 16:00:20,645 utils.py[line:218] - WARNING - ���Է����1������... -2024-04-12 16:00:20,656 utils.py[line:227] - WARNING - ���ӳɹ� -2024-04-12 16:00:27,391 utils.py[line:218] - WARNING - ���Է����1������... -2024-04-12 16:00:27,391 utils.py[line:227] - WARNING - ���ӳɹ� -2024-04-12 16:00:27,391 utils.py[line:218] - WARNING - ���Է����1������... -2024-04-12 16:00:27,392 utils.py[line:227] - WARNING - ���ӳɹ� -2024-04-12 16:00:27,819 utils.py[line:296] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 16:00:32,820 utils.py[line:218] - WARNING - ���Է����1������... -2024-04-12 16:00:34,822 utils.py[line:224] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-12 17:26:30,849 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:26:30,920 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:26:30,920 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:26:30,921 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:26:38,869 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 17:26:39,137 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 17:27:44,530 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:27:46,536 utils.py[line:294] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-12 17:27:51,537 utils.py[line:288] - WARNING - ���Է����2������... -2024-04-12 17:27:51,538 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:27:51,538 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:27:51,538 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:27:55,825 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 17:27:56,084 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 17:32:38,993 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:32:38,993 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:32:38,993 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:32:38,994 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:32:46,514 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 17:32:46,795 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 17:33:09,989 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:33:09,990 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:33:09,990 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:33:10,002 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:33:18,870 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-12 17:33:24,155 utils.py[line:269] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-12 17:34:44,607 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:34:46,609 utils.py[line:294] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-12 17:34:51,633 utils.py[line:288] - WARNING - ���Է����2������... -2024-04-12 17:34:53,648 utils.py[line:294] - ERROR - ��2������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-12 17:34:58,649 utils.py[line:288] - WARNING - ���Է����3������... -2024-04-12 17:34:58,660 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:34:58,661 utils.py[line:288] - WARNING - ���Է����1������... -2024-04-12 17:34:58,674 utils.py[line:297] - WARNING - ���ӳɹ� -2024-04-12 17:40:25,640 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:40:25,641 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:40:25,641 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:40:25,652 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:42:05,696 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:42:05,697 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:42:05,697 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:42:05,698 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:42:54,830 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:42:54,830 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:42:54,831 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:42:54,842 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:43:57,387 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:43:57,388 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:43:57,388 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:43:57,398 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:44:18,977 utils.py[line:79] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 17:44:59,117 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:44:59,118 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:44:59,118 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:44:59,119 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:45:21,112 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:45:21,113 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 17:45:21,113 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 17:45:21,113 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:18:57,092 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:18:57,677 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:18:57,677 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:18:57,688 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:26:53,862 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:26:58,864 utils.py[line:300] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-04-12 21:27:03,865 utils.py[line:294] - WARNING - ���Է����2������... -2024-04-12 21:27:08,865 utils.py[line:300] - ERROR - ��2������ʧ��... 5�����������... - timed out -2024-04-12 21:27:13,866 utils.py[line:294] - WARNING - ���Է����3������... -2024-04-12 21:27:18,866 utils.py[line:300] - ERROR - ��3������ʧ��... 5�����������... - timed out -2024-04-12 21:27:23,867 utils.py[line:294] - WARNING - ���Է����4������... -2024-04-12 21:27:28,868 utils.py[line:300] - ERROR - ��4������ʧ��... 5�����������... - timed out -2024-04-12 21:27:33,868 utils.py[line:294] - WARNING - ���Է����5������... -2024-04-12 21:27:38,869 utils.py[line:300] - ERROR - ��5������ʧ��... 5�����������... - timed out -2024-04-12 21:27:43,870 utils.py[line:294] - WARNING - ���Է����6������... -2024-04-12 21:27:48,870 utils.py[line:300] - ERROR - ��6������ʧ��... 5�����������... - timed out -2024-04-12 21:27:53,870 utils.py[line:294] - WARNING - ���Է����7������... -2024-04-12 21:27:58,871 utils.py[line:300] - ERROR - ��7������ʧ��... 5�����������... - timed out -2024-04-12 21:28:03,872 utils.py[line:294] - WARNING - ���Է����8������... -2024-04-12 21:28:08,872 utils.py[line:300] - ERROR - ��8������ʧ��... 5�����������... - timed out -2024-04-12 21:28:34,518 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:28:35,533 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:28:35,534 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:28:35,587 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:28:52,207 utils.py[line:123] - ERROR - ���ձ�������ʧ��, �������: -timed out -2024-04-12 21:28:57,207 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:28:59,211 utils.py[line:300] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-12 21:30:22,505 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:30:22,518 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:30:22,518 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:30:22,568 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:30:37,173 utils.py[line:123] - ERROR - ���ձ�������ʧ��, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-12 21:30:39,173 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:30:41,187 utils.py[line:300] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-12 21:33:53,504 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:33:53,510 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:33:53,510 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:33:53,524 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:36:49,688 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:36:49,695 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:36:49,696 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-12 21:36:50,702 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-12 21:37:06,015 utils.py[line:123] - ERROR - ���ձ�������ʧ��, �������: -timed out -2024-04-12 21:37:08,017 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:23:04,258 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:23:09,286 utils.py[line:300] - ERROR - ��1������ʧ��... 5�����������... - timed out -2024-04-14 11:23:14,287 utils.py[line:294] - WARNING - ���Է����2������... -2024-04-14 11:23:20,516 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:23:20,517 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:23:20,517 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:23:20,517 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:27:10,903 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:27:12,942 utils.py[line:300] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-14 11:27:17,952 utils.py[line:294] - WARNING - ���Է����2������... -2024-04-14 11:27:17,962 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:27:17,962 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:27:17,973 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:27:38,723 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:27:38,723 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:27:38,723 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:27:38,723 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:27:41,504 utils.py[line:79] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-14 11:27:43,505 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:27:43,516 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:27:43,516 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:27:43,526 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:28:21,307 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:28:22,821 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-14 11:28:22,821 utils.py[line:294] - WARNING - ���Է����1������... -2024-04-14 11:28:22,831 utils.py[line:303] - WARNING - ���ӳɹ� -2024-04-15 14:06:06,148 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:06:06,226 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:06:06,227 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:06:06,237 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:06:53,528 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:06:55,531 utils.py[line:303] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:07:00,531 utils.py[line:297] - WARNING - ���Է����2������... -2024-04-15 14:07:00,542 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:07:00,542 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:07:00,553 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:09:43,540 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:09:43,541 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:09:43,541 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:09:43,552 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:11:13,523 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:11:15,527 utils.py[line:303] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:11:20,527 utils.py[line:297] - WARNING - ���Է����2������... -2024-04-15 14:11:20,537 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:11:20,537 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:11:20,548 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:11:56,916 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:11:58,430 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:11:58,430 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:11:58,440 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:27:14,489 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:27:16,504 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:27:16,504 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:27:16,515 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:29:19,672 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:29:21,675 utils.py[line:303] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:29:26,676 utils.py[line:297] - WARNING - ���Է����2������... -2024-04-15 14:29:26,686 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:29:26,686 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:29:26,697 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:31:30,113 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:31:32,117 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:31:32,117 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:31:32,118 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:34:32,487 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:34:34,490 utils.py[line:303] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:34:39,491 utils.py[line:297] - WARNING - ���Է����2������... -2024-04-15 14:34:39,502 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:34:39,502 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:34:39,512 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:35:09,026 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:35:11,030 utils.py[line:303] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:35:16,031 utils.py[line:297] - WARNING - ���Է����2������... -2024-04-15 14:35:16,041 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:35:16,041 utils.py[line:297] - WARNING - ���Է����1������... -2024-04-15 14:35:16,052 utils.py[line:306] - WARNING - ���ӳɹ� -2024-04-15 14:39:41,098 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:39:43,111 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:39:43,111 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:39:43,122 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:42:09,905 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:42:11,407 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:42:11,407 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:42:11,418 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:42:39,954 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:42:41,958 utils.py[line:306] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:42:46,959 utils.py[line:300] - WARNING - ���Է����2������... -2024-04-15 14:42:46,970 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:42:46,970 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:42:46,970 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:43:29,921 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:43:31,934 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:43:31,934 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:43:31,945 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:47:07,042 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:47:09,045 utils.py[line:306] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:47:14,046 utils.py[line:300] - WARNING - ���Է����2������... -2024-04-15 14:47:16,049 utils.py[line:306] - ERROR - ��2������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:47:24,585 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:47:25,589 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:47:25,589 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:47:25,600 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:52:15,919 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:52:17,931 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:52:17,931 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:52:17,942 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:54:01,800 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:54:01,801 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:54:01,801 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:54:01,801 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:56:07,759 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:56:09,762 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:56:09,762 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:56:09,773 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:56:23,163 utils.py[line:85] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-15 14:56:50,540 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:56:52,544 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:56:52,544 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:56:52,555 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:57:16,989 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:57:17,992 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:57:17,992 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:57:18,003 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:57:50,728 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:57:52,745 utils.py[line:306] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:57:54,886 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:57:55,889 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:57:55,889 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:57:55,900 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:58:24,717 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:58:26,723 utils.py[line:306] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 14:58:31,724 utils.py[line:300] - WARNING - ���Է����2������... -2024-04-15 14:58:31,735 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 14:58:31,735 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 14:58:31,745 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 15:01:50,862 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 15:01:52,865 utils.py[line:306] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 15:01:57,866 utils.py[line:300] - WARNING - ���Է����2������... -2024-04-15 15:01:57,876 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 15:01:57,876 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 15:01:57,887 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 15:03:20,362 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 15:03:20,363 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 15:03:20,363 utils.py[line:300] - WARNING - ���Է����1������... -2024-04-15 15:03:20,363 utils.py[line:309] - WARNING - ���ӳɹ� -2024-04-15 15:13:38,039 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:13:40,072 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:13:40,072 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:13:40,083 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:16:08,840 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:16:10,845 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 15:16:15,845 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 15:16:15,856 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:16:15,856 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:16:15,857 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:17:51,706 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:17:51,706 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:17:51,706 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:17:51,707 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:20:08,871 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:20:10,875 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 15:20:15,875 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 15:20:15,886 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:20:15,886 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:20:15,896 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:39:51,103 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:39:53,106 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:39:53,106 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:39:53,116 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:42:11,162 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:42:13,166 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:42:13,166 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:42:13,167 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:42:48,239 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:42:49,243 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:42:49,243 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:42:49,254 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:51:25,651 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:51:27,653 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:51:27,653 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:51:27,664 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:51:49,787 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:51:51,802 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:51:53,805 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 15:51:58,805 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 15:51:58,816 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:51:58,816 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:51:58,827 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:53:13,158 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:53:15,161 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 15:53:20,162 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 15:53:20,172 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:53:20,172 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:53:20,183 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:54:36,613 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:54:38,616 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:54:38,616 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:54:38,626 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:55:54,974 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:55:56,978 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 15:56:01,979 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 15:56:01,990 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:56:01,990 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:56:02,001 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:56:52,264 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:56:53,767 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:56:53,767 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:56:53,777 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:57:33,177 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:57:35,190 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 15:57:40,190 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 15:57:40,201 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:57:40,201 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:57:40,212 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:57:51,525 utils.py[line:86] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-15 15:57:58,151 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:57:58,152 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 15:57:58,152 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 15:57:58,162 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:08:25,860 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:08:27,862 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:08:27,862 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:08:27,873 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:09:39,183 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:09:40,698 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:09:40,698 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:09:40,709 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:13:45,822 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:13:47,827 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:13:47,827 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:13:47,838 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:15:07,888 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:15:09,891 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:15:09,891 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:15:09,892 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:17:17,434 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:17:19,439 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 16:17:24,439 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 16:17:24,450 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:17:24,450 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:17:24,461 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:19:45,946 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:19:47,959 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:19:47,959 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:19:47,970 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:21:41,825 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:21:42,826 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:21:42,826 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:21:42,837 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:21:50,789 utils.py[line:282] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-15 16:21:55,887 utils.py[line:282] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-15 16:24:56,215 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:24:58,223 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 16:25:03,223 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 16:25:05,440 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:25:06,941 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:25:06,941 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:25:06,941 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:25:17,396 utils.py[line:282] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-15 16:25:22,546 utils.py[line:282] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-15 16:28:22,439 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:28:22,440 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:28:22,440 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:28:22,452 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:28:29,646 utils.py[line:282] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-15 16:31:16,121 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:31:16,121 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:31:16,121 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:31:16,122 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:32:10,830 utils.py[line:86] - ERROR - ���ӳ���, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-15 16:32:28,367 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:32:28,368 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 16:32:28,368 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 16:32:28,378 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 17:02:55,008 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 17:02:57,012 utils.py[line:307] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 17:03:02,013 utils.py[line:301] - WARNING - ���Է����2������... -2024-04-15 17:03:02,024 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 17:03:02,024 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 17:03:02,034 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 17:08:21,572 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 17:08:21,573 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 17:08:21,573 utils.py[line:301] - WARNING - ���Է����1������... -2024-04-15 17:08:21,574 utils.py[line:310] - WARNING - ���ӳɹ� -2024-04-15 17:09:29,690 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 17:09:31,695 utils.py[line:309] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-15 17:09:36,695 utils.py[line:303] - WARNING - ���Է����2������... -2024-04-15 17:09:36,696 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 17:09:36,696 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 17:09:36,708 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 17:10:18,170 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 17:10:20,172 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 17:10:20,172 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 17:10:20,183 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 19:11:12,109 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 19:11:12,138 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 19:11:12,138 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 19:11:12,149 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 19:40:16,318 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 19:40:18,323 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 19:40:18,323 utils.py[line:303] - WARNING - ���Է����1������... -2024-04-15 19:40:18,323 utils.py[line:312] - WARNING - ���ӳɹ� -2024-04-15 20:07:58,511 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-15 20:08:00,015 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-15 20:08:00,015 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-15 20:08:00,016 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-18 15:11:54,688 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-18 15:11:54,709 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-18 15:11:54,709 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-18 15:11:54,719 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-18 15:15:38,439 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-18 15:15:40,459 utils.py[line:316] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-18 15:15:45,467 utils.py[line:310] - WARNING - ���Է����2������... -2024-04-18 15:15:45,478 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-18 15:15:45,478 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-18 15:15:45,489 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 09:57:23,873 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 09:57:23,903 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 09:57:23,903 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 09:57:23,914 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:17:16,316 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:17:17,829 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:17:17,829 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:17:17,840 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:19:59,664 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:20:00,678 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:20:00,678 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:20:00,678 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:20:08,698 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:13,831 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:18,942 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:24,053 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:29,158 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:34,311 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:39,451 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:44,552 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:49,663 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:54,766 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:20:59,919 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:21:05,030 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:21:06,181 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-19 13:21:06,183 utils.py[line:130] - ERROR - ���ձ�������ʧ��, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-19 13:21:08,183 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:21:10,183 utils.py[line:316] - ERROR - ��1������ʧ��... 5�����������... - [WinError 10061] ����Ŀ�����������ܾ����޷����ӡ� -2024-04-19 13:26:31,129 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:26:31,129 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:26:31,130 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:26:31,130 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:26:39,121 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:26:44,223 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:26:49,355 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:26:54,443 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:26:59,530 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:04,616 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:09,702 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:14,793 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:19,881 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:25,015 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:30,106 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:35,193 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:40,278 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:45,370 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:50,462 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:27:55,559 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:00,645 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:05,733 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:10,821 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:15,908 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:20,985 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:38,761 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:28:40,266 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:28:40,266 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:28:40,276 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:28:48,903 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:54,005 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:28:59,105 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:04,206 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:09,304 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:14,409 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:19,511 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:21,756 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-19 13:29:21,757 utils.py[line:130] - ERROR - ���ձ�������ʧ��, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-19 13:29:27,034 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:29:29,037 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:29:29,037 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:29:29,048 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:29:36,287 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:41,391 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:46,488 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:29:50,960 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-19 13:29:50,962 utils.py[line:130] - ERROR - ���ձ�������ʧ��, �������: -[WinError 10054] Զ������ǿ�ȹر���һ�����е����ӡ� -2024-04-19 13:29:52,963 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:36:00,029 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:36:00,030 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:36:00,030 utils.py[line:310] - WARNING - ���Է����1������... -2024-04-19 13:36:00,040 utils.py[line:319] - WARNING - ���ӳɹ� -2024-04-19 13:36:07,629 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:36:12,719 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:36:17,807 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:36:22,939 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:36:28,031 utils.py[line:291] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:42:18,423 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 13:42:18,424 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 13:42:18,424 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 13:42:18,435 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 13:42:26,173 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:42:31,310 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:42:36,398 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:06,790 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 13:51:06,791 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 13:51:06,791 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 13:51:06,802 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 13:51:14,685 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:19,780 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:24,872 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:29,962 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:35,061 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:40,149 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:45,244 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:50,333 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:51:55,423 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:00,509 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:05,602 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:10,691 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:15,779 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:20,867 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:25,955 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:31,053 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:36,140 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:41,231 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:46,317 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:51,508 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 13:52:56,663 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:01:21,268 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:01:22,771 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:01:22,771 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:01:22,782 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:02:23,518 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:02:23,519 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:02:23,519 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:02:23,530 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:03:55,610 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:03:55,610 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:03:55,611 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:03:55,622 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:04:03,193 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:04:08,292 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:04:13,392 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:04:18,487 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:04:23,584 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:04:28,677 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:04:33,763 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:05:30,523 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:05:30,524 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:05:30,524 utils.py[line:316] - WARNING - ���Է����1������... -2024-04-19 14:05:30,534 utils.py[line:325] - WARNING - ���ӳɹ� -2024-04-19 14:05:38,568 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out -2024-04-19 14:05:43,681 utils.py[line:293] - ERROR - �������ָ��ʧ�ܣ��������ͣ�timed out diff --git a/root_dir.py b/root_dir.py deleted file mode 100644 index 754b950..0000000 --- a/root_dir.py +++ /dev/null @@ -1,5 +0,0 @@ - -import pathlib - -file_path = pathlib.Path(__file__) -ROOT_DIR = file_path.parent \ No newline at end of file diff --git a/utils.py b/utils.py deleted file mode 100644 index 4954707..0000000 --- a/utils.py +++ /dev/null @@ -1,516 +0,0 @@ - -import cv2 - -import numpy as np -from genetic_selection import GeneticSelectionCV -from sklearn.metrics import confusion_matrix, classification_report -from sklearn.model_selection import train_test_split -from sklearn.tree import DecisionTreeClassifier -import logging -import os -import shutil -import time -import socket - - - -def read_envi_ascii(file_name, save_xy=False, hdr_file_name=None): - """ - Read envi ascii file. Use ENVI ROI Tool -> File -> output ROIs to ASCII... - - :param file_name: file name of ENVI ascii file - :param hdr_file_name: hdr file name for a "BANDS" vector in the output - :param save_xy: save the x, y position on the first two cols of the result vector - :return: dict {class_name: vector, ...} - """ - number_line_start_with = "; Number of ROIs: " - roi_name_start_with, roi_npts_start_with = "; ROI name: ", "; ROI npts:" - data_start_with, data_start_with2, data_start_with3 = "; ID", "; ID", "; ID" - class_num, class_names, class_nums, vectors = 0, [], [], [] - with open(file_name, 'r') as f: - for line_text in f: - if line_text.startswith(number_line_start_with): - class_num = int(line_text[len(number_line_start_with):]) - elif line_text.startswith(roi_name_start_with): - class_names.append(line_text[len(roi_name_start_with):-1]) - elif line_text.startswith(roi_npts_start_with): - class_nums.append(int(line_text[len(roi_name_start_with):-1])) - elif line_text.startswith(data_start_with) or line_text.startswith(data_start_with2) or line_text.startswith(data_start_with3): - col_list = list(filter(None, line_text[1:].split(" "))) - assert (len(class_names) == class_num) and (len(class_names) == len(class_nums)) - break - elif line_text.startswith(";"): - continue - for vector_rows in class_nums: - vector_str = '' - for i in range(vector_rows): - vector_str += f.readline() - vector = np.fromstring(vector_str, dtype=float, sep=" ").reshape(-1, len(col_list)) - assert vector.shape[0] == vector_rows - vector = vector[:, 3:] if not save_xy else vector[:, 1:] - vectors.append(vector) - f.readline() # suppose to read a blank line - if hdr_file_name is not None: - import re - with open(hdr_file_name, 'r') as f: - hdr_info = f.read() - bands = re.findall(r"wavelength = {[^{}]+}", hdr_info, flags=re.IGNORECASE | re.MULTILINE) - bands_num = re.findall(r"bands\s*=\s*(\d+)", hdr_info, flags=re.I) - if (len(bands) == 0) or len(bands_num) == 0: - Warning("The given hdr file is invalid, can't find bands = ? or wavelength = {?}.") - else: - bands = re.findall(r'{[^{}]+}', bands[0], flags=re.MULTILINE)[0][3:-2] - bands = bands.split(',\n') - bands = np.asarray(bands, dtype=float) - bands_num = int(bands_num[0]) - if bands_num == bands.shape[0]: - bands = np.array(bands, dtype=float) - vectors.append(bands) - class_names.append("BANDS") - else: - Warning("The given hdr file is invalid, bands num is not equal to wavelength.") - return dict(zip(class_names, vectors)) - - -def ga_feature_extraction(data_x, data_y): - ''' - 使用遗传算法进行特征提取 - :param data_x: 特征 - :param data_y: 类别 - ''' - Xtrain, Xtest, Ytrain, Ytest = train_test_split(data_x, data_y, test_size=0.3) - clf = DecisionTreeClassifier(random_state=3) - selector = GeneticSelectionCV(clf, cv=30, - verbose=1, - scoring="accuracy", - max_features=10, - n_population=500, - crossover_proba=0.6, - mutation_proba=0.3, - n_generations=300, - crossover_independent_proba=0.6, - mutation_independent_proba=0.1, - tournament_size=10, - n_gen_no_change=10, - caching=True, - n_jobs=-1) - selector = selector.fit(Xtrain, Ytrain) - Xtrain_ga, Xtest_ga = Xtrain[:, selector.support_], Xtest[:, selector.support_] - clf = clf.fit(Xtrain_ga, Ytrain) - print(np.where(selector.support_ == True)) - y_pred = clf.predict(Xtest_ga) - print(classification_report(Ytest, y_pred)) - print(confusion_matrix(Ytest, y_pred)) - - -def read_raw(file_name, shape=None, setect_bands=None, cut_shape=None): - ''' - 读取raw文件 - :param file_name: 文件名 - :param setect_bands: 选择的波段 - :return: 波段数据 - ''' - if shape is None: - shape = (692, 272, 384) - with open(file_name, 'rb') as f: - data = np.frombuffer(f.read(), dtype=np.float32).reshape(shape).transpose(0, 2, 1) - if setect_bands is not None: - data = data[:, :, setect_bands] - if cut_shape is not None: - data = data[: cut_shape[0], : cut_shape[1], :] - return data - - -def save_raw(file_name, data): - ''' - 保存raw文件 - :param file_name: 文件名 - :param data: 数据 - ''' - data = data.transpose(0, 2, 1) - # 将data转换为一维数组 - data = data.reshape(-1) - with open(file_name, 'wb') as f: - f.write(data.astype(np.float32).tobytes()) - - -def read_rgb(file_name): - ''' - 读取rgb文件 - :param file_name: 文件名 - :return: rgb数据 - ''' - data = cv2.imread(file_name) - data = cv2.cvtColor(data, cv2.COLOR_BGR2RGB) - #给一个颜色对应的字典,用于将rgb转换为类别,白色对应0,黄色对应1,青色对应2,红色对应3,绿色对应4,蓝色对应5 - color_dict = {(255, 255, 255): 0, (255, 255, 0): 1, (0, 255, 255): 2, (255, 0, 0): 3, (0, 255, 0): 4, (0, 0, 255): 5} - # 保存图片的形状,用于将一维数组转换为三维数组 - shape = data.shape - # 将rgb转换为类别 - data = data.reshape(-1, 3).tolist() - # 将rgb转换为类别 - mapped_data = [] - - for i, color in enumerate(data): - mapped_value = color_dict.get(tuple(color)) - if mapped_value is None: - print("No mapping found for color", color, "at index", i) - else: - mapped_data.append(mapped_value) - # 将一维数组转换为三维数组 - data = np.array(mapped_data).reshape(shape[0], shape[1]) - return data - - -def read_data(raw_path, rgb_path, shape=None, setect_bands=None, blk_size=4, cut_shape=None, dp=False): - ''' - 读取数据 - :param raw_path: raw文件路径 - :param rgb_path: rgb文件路径 - :param setect_bands: 选择的波段 - :return: 波段数据,rgb数据 - ''' - if shape is None: - shape = (692, 272, 384) - with open(raw_path, 'rb') as f: - raw = np.frombuffer(f.read(), dtype=np.float32).reshape(shape).transpose(0, 2, 1) - if setect_bands is not None: - raw = raw[:, :, setect_bands] - color_dict = {(255, 255, 255): 0, (255, 255, 0): 1, (0, 255, 255): 2, (255, 0, 0): 3, (0, 255, 0): 4, - (0, 0, 255): 5} - rgb = cv2.imread(rgb_path) - rgb = cv2.cvtColor(rgb, cv2.COLOR_BGR2RGB) - if cut_shape is not None: - raw = raw[ :cut_shape[0], :cut_shape[1], :] - rgb = rgb[ :cut_shape[0], :cut_shape[1], :] - data_x = [] - data_y = [] - for i in range(0, rgb.shape[0], blk_size): - for j in range(0, rgb.shape[1], blk_size): - x = raw[i:i + blk_size, j:j + blk_size, :] - y = rgb[i:i + blk_size, j:j + blk_size] - # # 取y的第三行第三列的像素值,判断该像素值是否在color_dict中,如果在则将x和y添加到data_x和data_y中 - # y = tuple(y[2, 2, :]) - # if y in color_dict.keys(): - # data_x.append(x) - # data_y.append(color_dict[y]) - # 取y的中心点像素值,判断该像素值是否在color_dict中,如果在则将x和y添加到data_x和data_y中 - y = tuple(y[blk_size//2, blk_size//2, :]) - if y in color_dict.keys(): - data_x.append(x) - data_y.append(color_dict[y]) - data_x = np.array(data_x) - data_y = np.array(data_y).astype(np.uint8) - return data_x, data_y - - -def try_connect(connect_ip: str, port_number: int, is_repeat: bool = False, max_reconnect_times: int = 50) -> ( - bool, socket.socket): - """ - 尝试连接. - - :param is_repeat: 是否是重新连接 - :param max_reconnect_times:最大重连次数 - :return: (连接状态True为成功, Socket / None) - """ - reconnect_time = 0 - while reconnect_time < max_reconnect_times: - logging.warning(f'尝试{"重新" if is_repeat else ""}发起第{reconnect_time + 1}次连接...') - try: - connected_sock = PreSocket(socket.AF_INET, socket.SOCK_STREAM) - connected_sock.connect((connect_ip, port_number)) - except Exception as e: - reconnect_time += 1 - logging.error(f'第{reconnect_time}次连接失败... 5秒后重新连接...\n {e}') - time.sleep(5) - continue - logging.warning(f'{"重新" if is_repeat else ""}连接成功') - return True, connected_sock - return False, None - - -class PreSocket(socket.socket): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.pre_pack = b'' - self.settimeout(5) - - def receive(self, *args, **kwargs): - if self.pre_pack == b'': - return self.recv(*args, **kwargs) - else: - data_len = args[0] - required, left = self.pre_pack[:data_len], self.pre_pack[data_len:] - self.pre_pack = left - return required - - def set_prepack(self, pre_pack: bytes): - temp = self.pre_pack - self.pre_pack = temp + pre_pack - - -class DualSock(PreSocket): - def __init__(self, connect_ip='127.0.0.1', recv_port: int = 21122, send_port: int = 21123): - super().__init__() - received_status, self.received_sock = try_connect(connect_ip=connect_ip, port_number=recv_port) - send_status, self.send_sock = try_connect(connect_ip=connect_ip, port_number=send_port) - self.status = received_status and send_status - - def send(self, *args, **kwargs) -> int: - return self.send_sock.send(*args, **kwargs) - - def receive(self, *args, **kwargs) -> bytes: - return self.received_sock.receive(*args, **kwargs) - - def set_prepack(self, pre_pack: bytes): - self.received_sock.set_prepack(pre_pack) - - def reconnect(self, connect_ip='127.0.0.1', recv_port:int = 21122, send_port: int = 21123): - received_status, self.received_sock = try_connect(connect_ip=connect_ip, port_number=recv_port) - send_status, self.send_sock = try_connect(connect_ip=connect_ip, port_number=send_port) - return received_status and send_status - - -def receive_sock(recv_sock: PreSocket, pre_pack: bytes = b'', time_out: float = -1.0, time_out_single=5e20) -> ( -bytes, bytes): - """ - 从指定的socket中读取数据.自动阻塞,如果返回的数据为空则说明连接出现问题,需要重新连接。 - - :param recv_sock: 指定sock - :param pre_pack: 上一包的粘包内容 - :param time_out: 每隔time_out至少要发来一次指令,否则认为出现问题进行重连,小于0则为一直等 - :param time_out_single: 单次指令超时时间,单位是秒 - :return: data, next_pack - """ - recv_sock.set_prepack(pre_pack) - # 开头校验 - time_start_recv = time.time() - while True: - if time_out > 0: - if (time.time() - time_start_recv) > time_out: - logging.error(f'指令接收超时') - return b'', b'' - try: - temp = recv_sock.receive(1) - except ConnectionError as e: - logging.error(f'连接出错, 错误代码:\n{e}') - return b'', b'' - except TimeoutError as e: - # logging.error(f'超时了,错误代码: \n{e}') - logging.info('运行中,等待指令..') - continue - except socket.timeout as e: - logging.info('运行中,等待指令..') - continue - except Exception as e: - logging.error(f'遇见未知错误,错误代码: \n{e}') - return b'', b'' - if temp == b'\xaa': - break - - # 接收开头后,开始进行时间记录 - time_start_recv = time.time() - - # 获取报文长度 - temp = b'' - while len(temp) < 4: - if (time.time() - time_start_recv) > time_out_single: - logging.error(f'单次指令接收超时') - return b'', b'' - try: - temp += recv_sock.receive(1) - except Exception as e: - logging.error(f'接收报文的长度不正确, 错误代码: \n{e}') - return b'', b'' - try: - data_len = int.from_bytes(temp, byteorder='big') - except Exception as e: - logging.error(f'转换失败,错误代码 \n{e}') - return b'', b'' - - # 读取报文内容 - temp = b'' - while len(temp) < data_len: - if (time.time() - time_start_recv) > time_out_single: - logging.error(f'单次指令接收超时') - return b'', b'' - try: - temp += recv_sock.receive(data_len) - except Exception as e: - logging.error(f'接收报文内容失败, 错误代码: \n{e}') - return b'', b'' - data, next_pack = temp[:data_len], temp[data_len:] - recv_sock.set_prepack(next_pack) - next_pack = b'' - - # 进行数据校验 - temp = b'' - while len(temp) < 3: - if (time.time() - time_start_recv) > time_out_single: - logging.error(f'单次指令接收超时') - return b'', b'' - try: - temp += recv_sock.receive(1) - except Exception as e: - logging.error(f'接收报文校验失败, 错误代码: \n{e}') - return b'', b'' - if temp == b'\xff\xff\xbb': - return data, next_pack - else: - logging.error(f"接收了一个完美的只错了校验位的报文") - return b'', b'' - - -def parse_protocol(data: bytes) -> (str, any): - ''' - 指令转换 - :param data: 接收到的报文 - :return: 指令类型,指令内容 - ''' - try: - assert len(data) > 4 - except AssertionError: - logging.error('指令转换失败,长度不足5') - return '', None - cmd, data = data[:4], data[4:] - cmd = cmd.decode('ascii').strip().upper() - if cmd == 'IM': - n_rows, n_cols, img = data[:2], data[2:4], data[4:] - try: - n_rows, n_cols = [int.from_bytes(x, byteorder='big') for x in [n_rows, n_cols]] - except Exception as e: - logging.error(f'长宽转换失败, 错误代码{e}, 报文大小: n_rows:{n_rows}, n_cols: {n_cols}') - return '', None - try: - assert n_rows * n_cols * 3 == len(img) - except AssertionError: - logging.error('图像指令IM转换失败,数据长度错误') - return '', None - img = np.frombuffer(img, dtype=np.uint8).reshape((n_rows, n_cols, -1)) - return cmd, img - - -def ack_sock(send_sock: socket.socket, cmd_type: str) -> bool: - ''' - 发送应答 - :param cmd_type:指令类型 - :param send_sock:指定sock - :return:是否发送成功 - ''' - msg = b'\xaa\x00\x00\x00\x05' + (' A' + cmd_type).upper().encode('ascii') + b'\xff\xff\xff\xbb' - try: - send_sock.send(msg) - except Exception as e: - logging.error(f'发送应答失败,错误类型:{e}') - return False - return True - - -def done_sock(send_sock: socket.socket, cmd_type: str, result = '') -> bool: - ''' - 发送任务完成指令 - :param send_sock: 指定sock - :param cmd_type: 指令类型 - :param result: 数据 - :return: 是否发送成功 - ''' - cmd = cmd_type.strip().upper() - if cmd_type == 'IM': - result = result.encode() - # 指令4位 - length = len(result) + 4 - length = length.to_bytes(4, byteorder='big') - # msg = b'\xaa' + length + (' D' + cmd).upper().encode('ascii') + result + b'\xff\xff\xbb' - msg = result - try: - send_sock.send(msg) - except Exception as e: - logging.error(f'发送完成指令失败,错误类型:{e}') - return False - return True - -def simple_sock(send_sock: socket.socket, cmd_type: str, result) -> bool: - ''' - 发送任务完成指令 - :param cmd_type:指令类型 - :param send_sock:指定sock - :param result:数据 - :return:是否发送成功 - ''' - cmd_type = cmd_type.strip().upper() - if cmd_type == 'IM': - if result == 0: - msg = b'S' - elif result == 1: - msg = b'Z' - elif result == 2: - msg = b'Q' - elif cmd_type == 'TR': - msg = b'A' - elif cmd_type == 'MD': - msg = b'D' - elif cmd_type == 'KM': - msg = b'K' - result = result.encode('ascii') - result = b',' + result - length = len(result) - msg = msg + length.to_bytes(4, 'big') + result - try: - send_sock.send(msg) - except Exception as e: - logging.error(f'发送完成指令失败,错误类型:{e}') - return False - return True - -def mkdir_if_not_exist(dir_name, is_delete=False): - """ - 创建文件夹 - :param dir_name: 文件夹 - :param is_delete: 是否删除 - :return: 是否成功 - """ - try: - if is_delete: - if os.path.exists(dir_name): - shutil.rmtree(dir_name) - print('[Info] 文件夹 "%s" 存在, 删除文件夹.' % dir_name) - - if not os.path.exists(dir_name): - os.makedirs(dir_name) - print('[Info] 文件夹 "%s" 不存在, 创建文件夹.' % dir_name) - return True - except Exception as e: - print('[Exception] %s' % e) - return False - -def create_file(file_name): - """ - 创建文件 - :param file_name: 文件名 - :return: None - """ - if os.path.exists(file_name): - print("文件存在:%s" % file_name) - return False - # os.remove(file_name) # 删除已有文件 - if not os.path.exists(file_name): - print("文件不存在,创建文件:%s" % file_name) - open(file_name, 'a').close() - return True - - -class Logger(object): - def __init__(self, is_to_file=False, path=None): - self.is_to_file = is_to_file - if path is None: - path = "Astragalins.log" - self.path = path - create_file(path) - - def log(self, content): - if self.is_to_file: - with open(self.path, "a") as f: - print(time.strftime("[%Y-%m-%d_%H-%M-%S]:"), file=f) - print(content, file=f) - else: - print(content) \ No newline at end of file