托辊皮带检测

凤阳 3dc7bd10a7 requirements.txt 3 anni fa
deep-hough-transform-master 46b2185aee second commit 3 anni fa
model 46b2185aee second commit 3 anni fa
src 46b2185aee second commit 3 anni fa
test_sources 46b2185aee second commit 3 anni fa
README.md ad7a70bb33 README 3 anni fa
requirements.txt 3dc7bd10a7 requirements.txt 3 anni fa

README.md

├── deep-hough-transform-master #深度霍夫直线检测训练算法 https://arxiv.org/abs/2003.04676
│   ├── basic_ops.py
│   ├── chamfer_distance
│   │   ├── chamfer_distance.cpp
│   │   ├── chamfer_distance.cu
│   │   ├── chamfer_distance.py
│   │   └── init.py
│   ├── config.yml
│   ├── data #训练数据存放路径
│   ├── dataloader.py
│   ├── forward.py
│   ├── hungarian_matching.py
│   ├── init.py
│   ├── jittor_code
│   │   ├── basic_ops.py
│   │   ├── benchmark.py
│   │   ├── config.yml
│   │   ├── dataloader.py
│   │   ├── forward.py
│   │   ├── logger.py
│   │   ├── model
│   │   │   ├── backbone
│   │   │   │   └── fpn.py
│   │   │   ├── cuda_src.py
│   │   │   ├── dht.py
│   │   │   └── network.py
│   │   ├── README.md
│   │   └── utils.py
│   ├── LaTeX #生成论文LaTeX源代码
│   ├── logger.py #日志脚本
│   ├── metric.py
│   ├── model
│   │   ├── backbone
│   │   │   ├── fpn.py
│   │   │   ├── mobilenet.py
│   │   │   ├── res2net.py
│   │   │   ├── resnet.py
│   │   │   └── vgg_fpn.py
│   │   ├── _cdht
│   │   │   ├── build
│   │   │   │   ├── bdist.linux-x86_64
│   │   │   │   ├── lib.linux-x86_64-3.8
│   │   │   │   │   └── deep_hough.cpython-38-x86_64-linux-gnu.so
│   │   │   │   └── temp.linux-x86_64-3.8
│   │   │   │   ├── deep_hough_cuda_kernel.o
│   │   │   │   └── deep_hough_cuda.o
│   │   │   ├── deep_hough_cuda.cpp
│   │   │   ├── deep_hough_cuda_kernel.cu
│   │   │   ├── deep_hough.egg-info
│   │   │   │   ├── dependency_links.txt
│   │   │   │   ├── PKG-INFO
│   │   │   │   ├── SOURCES.txt
│   │   │   │   └── top_level.txt
│   │   │   ├── dht_func.py
│   │   │   ├── dist
│   │   │   │   └── deep_hough-0.0.0-py3.8-linux-x86_64.egg
│   │   │   └── setup.py
│   │   ├── dht.py
│   │   └── network.py
│   ├── pipeline.png
│   ├── README.md
│   ├── test_nkl.py #测试NKL数据脚本
│   ├── test_sel.py #测试SEL数据脚本
│   ├── train.py #训练脚本
│   └── utils.py
├── model #训练后的模型存放路径
│   ├── cb_dht #
│   │   ├── dht_r50_fpn_sel_c9a29d40.pth
│   │   └── dht_r50_nkl_d97b97138.pth
│   ├── cb_mask #皮带mask检测模型
│   │   └── best_dice_loss.pth
│   └── roller_yolo # 托辊位置检测模型,采用yolo5
│   └── best.pt
├── src
│   ├── edge_utils #直线检测模型
│   │   ├── backbone #用于提取深度CNN特征的模型(选其中一个)
│   │   │   ├── fpn.py
│   │   │   ├── mobilenet.py
│   │   │   ├── res2net.py
│   │   │   ├── resnet.py
│   │   │   └── vgg_fpn.py
│   │   ├── _cdht # deep-hough的安装脚本路径 https://github.com/Hanqer/deep-hough-transform
│   │   │   ├── deep_hough_cuda.cpp
│   │   │   ├── deep_hough_cuda_kernel.cu
│   │   │   ├── dht_func.py
│   │   │   └── setup.py #deep-hough安装脚本 安装命令:[python setup.py build; python setup.py install --user]
│   │   ├── basic_ops.py
│   │   ├── dht.py
│   │   ├── edge_detector.py
│   │   ├── edge_utils.py
│   │   ├── network.py
│   │   └── utils.py
│   ├── mask_utils #皮带mask检测模型 https://arxiv.org/abs/1808.00897v1
│   │   ├── build_BiSeNet.py
│   │   ├── build_contextpath.py
│   │   ├── mask_component_utils.py
│   ├── roller_utils# 托辊位置检测模型
│   │   ├── bbox_common_utils.py
│   ├── roller.py #托辊位置检测类
│   ├── geometry_utils.py #通用函数工具脚本
│   ├── belt.py #皮带的mask检测类
│   └── run.py #主方法函数入口
└── test_sources #测试数据集
│ ├── test_images #图像
│ │   ├── test2.jpg
│ │   └── test.jpg
│ └── test_videos #视频
│ │ ├── test2.mp4
│ │ ├── test3.mp4
│ │ ├── test4.mp4
│ │ └── test.mp4


basic_ops.py

class Line(object) #直线信息类
class LineAnnotation(object) #直线注释类(没有引用该类)
def line2mask(size, lines) #在mask图像中画出直线
def get_boundary_point(y, x, angle, H, W) #给出x、y和角度,返回与图像边缘相交的两个点坐标
def int2arc(k, num_directions) #int转弧度
def arc2int(theta, num_directions) #弧度转int(没有引用该方法)


utils.py

def draw_line(y, x, angle, image, color=(0, 0, 255), num_directions=24) #根据x、y坐标和角度画线(没有引用该方法)
def convert_line_to_hough(line, size=(32, 32)) #line2hough方法的附属方法
def line2hough(line, numAngle, numRho, size=(32, 32)) #将线转换为霍夫表示方式(类似于极坐标参数表示方法)(没有引用该方法)
def line2hough_float(line, numAngle, numRho, size=(32, 32)) #将线转换为霍夫表示方式(没有引用该方法)(没有引用该方法)
def reverse_mapping(point_list, numAngle, numRho, size=(32, 32)) #反向映射,将检测到的线方程转化到图像空间
def visulize_mapping(b_points, size, filename) #在图像上画线(没有引用该方法)
def caculate_precision(b_points, gt_coords, thresh=0.90) #计算精准度(没有引用该方法)
def caculate_recall(b_points, gt_coords, thresh=0.90) #计算召回(没有引用该方法)
def coords_sort(coords) #坐标排序(没有引用该方法)
def get_density(filename, x1, y1, x2, y2) #得到密度(没有引用该方法)
def local_search(coords, coords_ring, d=1) #没看懂
def overflow(x, size=400) #图像大小判断
def edge_align(coords, filename, size, division=9) #图像边缘对齐(没有引用该方法)


network.py

class Net(nn.Module) #模型选择(resnet18、resnet50、resnet101、resnext50、vgg16、mobilenetv2、res2net50、mobilenetv2)


edge_utils.py

def predict_single_image(model, image, size) #预测单张图像


edge_detector.py

class EdgeDetector(object) #边缘检测类


dht.py

class DHT_Layer(nn.Module) # 深度霍夫变换网络结构
class DHT(nn.Module) 深度霍夫变换的引用


geometry_utils.py

def _calc_abc_from_line_2d(point1, point2) #_get_line_cross_point函数的附属函数
def _get_line_cross_point(line1, line2) #通过两条直线的点坐标集合直接求出两条直线的交点坐标(不需要求出直线方程。line1:[point1,point2])
def kb_get_point(line, height, width) #通过直线方程和图片大小确定该直线与图像边缘相交的点坐标
def lines_point_to_angle_bisector(line1_points, line2_points, height, width) #通过两条直线的点坐标信息求出两条直线的角平分线与图像边缘的焦点
def get_bbox(point_1, point_2, width, height) #根据两条直线的点坐标集合和图像宽高求出两条直线和图像边缘围成的闭合图形点坐标集合并按顺时针方向排列
def points_to_area(top_point_line, down_point_line, width, height) #根据两条直线点坐标集合与图像边缘围成的闭合框面积
def points_to_line_k_b(point_list) #根据点坐标求直线方程
def lines_k_to_convert_belt_angle(k1, k2) #根据两条直线的斜率求其夹角
def lines_up_or_up_down(line_1, line_2, width, height) #判断上下边缘线
def _list_remove(lists, a) #列表移除元素


belt.py

class CbMaskDetection(object) #皮带mask检测类


run.py

class Detector(object) #画图、检测集合类
def predict_image(detector, image_path) #图像检测
def predict_video(video_path, detector) #视频检测
def main() #主函数


roller.py

class RollerDetection(object) #托辊检测类


build_contextpath.py

class resnet18(torch.nn.Module) #resnet18模型
class resnet101(torch.nn.Module) #resnet101模型
def build_contextpath(name) #模型选择


mask_component_utils.py

class RandomCrop(object) #在随机位置上裁剪给定的PIL图像(没有引用该类)
class OHEM_CrossEntroy_Loss(nn.Module) #交叉熵损失(没有引用该类)
def poly_lr_scheduler(optimizer, init_lr, iter, lr_decay_iter=1,max_iter=300, power=0.9) #学习率的多项衰减(没有引用该方法)
def get_label_info(csv_path) #获取语义标签的RGB数据及其对应的class(没有引用该方法)
def one_hot_it(label, label_info) #(没有引用该方法)
def one_hot_it_v11(label, label_info) #(没有引用该方法)
def one_hot_it_v11_dice(label, label_info) #(没有引用该方法)
def reverse_one_hot(image) #one_hot编码
def colour_code_segmentation(image, label_values) #彩色编码图像分割可视化(没有引用该方法)
def compute_global_accuracy(pred, label) #(没有引用该方法)
def fast_hist(a, b, n) #(没有引用该方法)
def per_class_iu(hist) #(没有引用该方法)
def cal_miou(miou_list, csv_path) #(没有引用该方法)
def group_weight(weight_group, module, norm_layer, lr) #(没有引用该方法)


build_BiSeNet.py

class ConvBlock(torch.nn.Module) #卷积块
class Spatial_path(torch.nn.Module) #Spatial Path部分,用于保存空间信息 https://zhuanlan.zhihu.com/p/47250633
class AttentionRefinementModule(torch.nn.Module) #Context Path部分,U形结构
class FeatureFusionModule(torch.nn.Module) #特征融合模块
class BiSeNet(torch.nn.Module) #BiSeNet模型


bbox_common_utils.py

def cal_dis_point_line(point, line_point) #求托辊关键点到皮带边缘线的距离
def fitting_straight_line_function(x, k, b) #直线方程表达式
def ignore_center(self, height, width, x_min, y_min, x_max, y_max) # 检查托辊框是否越界
def select_bbox(self, coordinate_list, width, height) #选择托辊框,将不符合规则的托辊框剔除
def justify_point_side(self, top_down_label_dict, points_list)#根据上下皮带边缘线进行托辊上下边缘位置分类
def get_roller_line(self, point_side_label, coordinate_list, top_down_label_dict, height, width)# 根据上下皮带边缘线挑选托辊框关键点并拟合直线
def get_roller_info(self, top_down_label_dict, coordinate_list, width, height) 主方法


运行程序

根据 https://github.com/Hanqer/deep-hough-transform 教程安装deep-hough
运行 run.py