基于深度学习的UNet的裂缝分割检测 建筑物裂缝识别 桥梁裂缝检测 (代码+界面+数据集)
UNet进行裂缝分割项目描述裂缝分割的任务是从道路图像或视频中识别并分割出裂缝。在本项目中我们使用UNet模型来检测裂缝。我们评估了不同损失函数的性能并比较了它们的结果。以下是实现的损失函数• 交叉熵损失Cross Entropy Loss• Dice损失Dice Loss• Dice交叉熵损失Dice Cross Entropy Loss• 焦点损失Focal Loss我们使用上述损失函数训练模型并通过Dice系数Dice Score 1 - Dice Loss评估其性能。需要注意的是Dice Score可能不是比较这些模型的唯一正确指标。安装下载项目安装依赖pipinstall-rrequirements.txt下载模型权重将使用Dice Loss训练的模型权重model.pt放入weights文件夹中。使用数据集下载数据集并将train和test文件夹放入data文件夹中结构如下data-| |-train-| |-images |-masks |-test -| |-images |-masks训练运行以下命令进行训练python train.py训练参数python train.py-husage: train.py[-h][--data DATA][--image_size IMAGE_SIZE][--save-dir SAVE_DIR][--epochs EPOCHS][--batch-size BATCH_SIZE][--lr LR][--weights WEIGHTS][--amp][--num-classes NUM_CLASSES]optional arguments: -h,--helpshow thishelpmessage andexit--dataDATA Path to root folder of data--image_sizeIMAGE_SIZE Input image size, default:512--save-dir SAVE_DIR Directory to save weights--epochsEPOCHS Number of epochs, default:5--batch-size BATCH_SIZE Batch size, default:12--lrLR Learning rate, default: 1e-5--weightsWEIGHTS Pretrained model, default: None--ampUse mixed precision --num-classes NUM_CLASSES Number of classes推理运行以下命令进行推理python inference.py--weightsweights/model.pt--inputassets/CFD_001_image.jpg推理参数python inference.py-husage: inference.py[-h][--weights WEIGHTS][--input INPUT][--output OUTPUT][--image-size IMAGE_SIZE][--view][--no-save][--conf-thresh CONF_THRESH]optional arguments: -h,--helpshow thishelpmessage andexit--weightsWEIGHTS Path to weightfile(default: last.pt)--inputINPUT Path to input image--outputOUTPUT Path to save mask image --image-size IMAGE_SIZE Input image size--viewVisualize image and mask --no-save Do not save the output masks --conf-thresh CONF_THRESH Confidence thresholdformask结果以下是不同损失函数的Dice Score结果损失函数Dice Score交叉熵损失0.9719Dice损失0.9804Dice交叉熵损失0.9754焦点损失0.9679