代码链接:https://github.com/malakar-soham/cnn-in-welding
对心脏(红色),肺部(绿色)和锁骨(蓝色)的胸部X光进行了分割
面积(或总强度)
质心
有关其方向的信息
来自“图像”的原始图像
图像分割
使用颜色显示严重性
使用图像矩测量严重性
使用的U-Net架构
每个蓝色框对应一个多通道特征图
通道数显示在框的顶部。
(x,y)尺寸位于框的左下边缘。
箭头表示不同的操作。
图层名称位于图层下方。
C1,C2,...。C7是卷积运算后的输出层
P1,P2,P3是最大池化操作的输出层
U1,U2,U3是上采样操作的输出层
A1,A2,A3是跳过连接。
左侧是收缩路径,其中应用了常规卷积和最大池化操作
图像尺寸逐渐减小,而深度逐渐增大。
右侧是扩展路径,在其中应用了(向上采样)转置卷积和常规卷积运算
在扩展路径中,图像尺寸逐渐增大,深度逐渐减小
为了获得更好的精确位置,在扩展的每个步骤中,我们都使用跳过连接,方法是将转置卷积层的输出与来自编码器的特征图在同一级别上连接:
A1 = U1 + C3
A2 = U2 + C2
A3 = U3 + C1
每次串联后,我们再次应用规则卷积,以便模型可以学习组装更精确的输出。
import numpy as np import cv2 import os import random import tensorflow as tf h,w = 512,512 def create_model(): inputs = tf.keras.layers.Input(shape=(h,w,3)) conv1 = tf.keras.layers.Conv2D(16,(3,3),activation='relu',padding='same')(inputs) pool1 = tf.keras.layers.MaxPool2D()(conv1) conv2 = tf.keras.layers.Conv2D(32,(3,3),activation='relu',padding='same')(pool1) pool2 = tf.keras.layers.MaxPool2D()(conv2) conv3 = tf.keras.layers.Conv2D(64,(3,3),activation='relu',padding='same')(pool2) pool3 = tf.keras.layers.MaxPool2D()(conv3) conv4 = tf.keras.layers.Conv2D(64,(3,3),activation='relu',padding='same')(pool3) upsm5 = tf.keras.layers.UpSampling2D()(conv4) upad5 = tf.keras.layers.Add()([conv3,upsm5]) conv5 = tf.keras.layers.Conv2D(32,(3,3),activation='relu',padding='same')(upad5) upsm6 = tf.keras.layers.UpSampling2D()(conv5) upad6 = tf.keras.layers.Add()([conv2,upsm6]) conv6 = tf.keras.layers.Conv2D(16,(3,3),activation='relu',padding='same')(upad6) upsm7 = tf.keras.layers.UpSampling2D()(conv6) upad7 = tf.keras.layers.Add()([conv1,upsm7]) conv7 = tf.keras.layers.Conv2D(1,(3,3),activation='relu',padding='same')(upad7) model = tf.keras.models.Model(inputs=inputs, outputs=conv7) return model images = [] labels = [] files = os.listdir('./dataset/images/') random.shuffle(files) for f in files: img = cv2.imread('./dataset/images/' + f) parts = f.split('_') label_name = './dataset/labels/' + 'W0002_' + parts[1] label = cv2.imread(label_name,2) img = cv2.resize(img,(w,h)) label = cv2.resize(label,(w,h)) images.append(img) labels.append(label) images = np.array(images) labels = np.array(labels) labels = np.reshape(labels, (labels.shape[0],labels.shape[1],labels.shape[2],1)) print(images.shape) print(labels.shape) images = images/255 labels = labels/255 model = tf.keras.models.load_model('my_model') #model = create_model() # uncomment this to create a new model print(model.summary()) model.compile(optimizer='adam', loss='binary_crossentropy',metrics=['accuracy']) model.fit(images,labels,epochs=100,batch_size=10) model.evaluate(images,labels) model.save('my_model')
该模型使用Adam优化器编译,由于只有两类(缺陷或没有缺陷),因此我们使用二进制交叉熵损失函数。我们使用10批次、100个epochs(在所有输入上运行模型的次数)。调整这些参数,模型性能可能会有很大的改善可能。
然后将图像转换为16位整数以便于图像操作。之后,算法将检测缺陷并通过颜色分级在视觉上标记缺陷的严重性,并根据缺陷的严重性为具有缺陷的像素分配权重。然后考虑加权像素,在此图像上计算图像力矩。最终将图像转换回8位整数,并以颜色分级及其严重性值显示输出图像。
import numpy as np import cv2 from google.colab.patches import cv2_imshow import os import random import tensorflow as tf h,w = 512,512 num_cases = 10 images = [] labels = [] files = os.listdir('./dataset/images/') random.shuffle(files) model = tf.keras.models.load_model('my_model') lowSevere = 1 midSevere = 2 highSevere = 4 for f in files[0:num_cases]: test_img = cv2.imread('./dataset/images/' + f) resized_img = cv2.resize(test_img,(w,h)) resized_img = resized_img/255 cropped_img = np.reshape(resized_img, (1,resized_img.shape[0],resized_img.shape[1],resized_img.shape[2])) test_out = model.predict(cropped_img) test_out = test_out[0,:,:,0]*1000 test_out = np.clip(test_out,0,255) resized_test_out = cv2.resize(test_out,(test_img.shape[1],test_img.shape[0])) resized_test_out = resized_test_out.astype(np.uint16) test_img = test_img.astype(np.uint16) grey = cv2.cvtColor(test_img, cv2.COLOR_BGR2GRAY) for i in range(test_img.shape[0]): for j in range(test_img.shape[1]): if(grey[i,j]>150 & resized_test_out[i,j]>40): test_img[i,j,1]=test_img[i,j,1] + resized_test_out[i,j] resized_test_out[i,j] = lowSevere elif(grey[i,j]<100 & resized_test_out[i,j]>40): test_img[i,j,2]=test_img[i,j,2] + resized_test_out[i,j] resized_test_out[i,j] = highSevere elif(resized_test_out[i,j]>40): test_img[i,j,0]=test_img[i,j,0] + resized_test_out[i,j] resized_test_out[i,j] = midSevere else: resized_test_out[i,j] = 0 M = cv2.moments(resized_test_out) maxMomentArea = resized_test_out.shape[1]*resized_test_out.shape[0]*highSevere print("0th Moment = " , (M["m00"]*100/maxMomentArea), "%") test_img = np.clip(test_img,0,255) test_img = test_img.astype(np.uint8) cv2_imshow(test_img) cv2.waitKey(0)
绿色表示存在严重缺陷的区域。
蓝色表示缺陷更严重的区域。
红色区域显示出最严重的缺陷。
原始图像
二进制图像(地面真相)
、
具有严重性的预测输出
原始图像
二进制图像(地面真相)
具有严重性的预测输出
原始图像
二进制图像(地面真相)
具有严重性的预测输出
数据集介绍: 这是一个非均匀的真实数据集,具有成对的真实雾度和相应的无雾度图像。这是第一个非齐次图像去模糊数据集,包含55个室外场景。在场景中引入了非均匀雾,使用专业雾发生器模拟雾场景的真实条件。 引用: @inproceedings{NH-Haze_2020, author = {Codruta O. Ancuti and Cosmin Ancuti and Radu Timofte}, t
Look into Person(LIP)是一个新的大规模数据集,专注于人的语义理解,该数据集包含 50,000 张图像,其中包含精心设计的像素注释、19 个语义人体部位标签和具有 16 个关键点的 2D 人体姿势。带注释的 50,000 张图像是从 COCO 数据集中裁剪的人物实例,大小大于 50 * 50。从真实场景收集的图像包含以具有挑战性的姿势和视图出现的人类、严重遮挡、各种外观和低分辨率。
全国机场信息包含全国所有民航机场, 高原机场, 高高原机场,特殊机场名单,每个机场上的机场IATA编号,机场ICAO编号,机场等级,机场海拔,机场性质,机场跑道数量,机场最大跑道长度,机场经度,机场纬度,机场运送人次,机场电话,机场地址,机场历年旅客吞吐量,机场历年货邮架次,机场历年起降架次等信息。
湖北省主要雨量站雨情数据,2000年至2022年最新 湖北省雨情数据,总共6000+(月均为4000左右站点)监测站点,包含行政区编码名称,站点编码名称,时间,时段降水量mm,时段长,降水历时,日降水量mm,天气等信息,数据总量2.6亿条,11G。