表面缺陷检测-DAGM 2007

1.DAGM 2007数据集介绍

2.实验

一把梭

TEST 8050,FP=5, FN=5

分类别

Class4: FP=1, FN=0

ClassOther: FP=0, FN=0

机器视觉技术交流 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,以下是一个使用 TensorFlow 对 DAGM 数据集进行缺陷检测的 Python 代码示例: ```python import tensorflow as tf import numpy as np import matplotlib.pyplot as plt # 加载数据集 train_data = np.load('dagm_train_data.npy') train_labels = np.load('dagm_train_labels.npy') test_data = np.load('dagm_test_data.npy') test_labels = np.load('dagm_test_labels.npy') # 创建模型 model = tf.keras.Sequential([ tf.keras.layers.Conv2D(16, (3, 3), activation='relu', input_shape=(128, 128, 1)), tf.keras.layers.MaxPooling2D((2, 2)), tf.keras.layers.Conv2D(32, (3, 3), activation='relu'), tf.keras.layers.MaxPooling2D((2, 2)), tf.keras.layers.Conv2D(64, (3, 3), activation='relu'), tf.keras.layers.MaxPooling2D((2, 2)), tf.keras.layers.Flatten(), tf.keras.layers.Dense(64, activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid') ]) # 编译模型 model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) # 训练模型 history = model.fit(train_data, train_labels, epochs=10, batch_size=32, validation_data=(test_data, test_labels)) # 评估模型 loss, accuracy = model.evaluate(test_data, test_labels) print('Test accuracy:', accuracy) # 绘制训练和验证准确率曲线 plt.plot(history.history['accuracy'], label='accuracy') plt.plot(history.history['val_accuracy'], label='val_accuracy') plt.xlabel('Epoch') plt.ylabel('Accuracy') plt.ylim([0.5, 1]) plt.legend(loc='lower right') plt.show() ``` 在这个例子中,我们使用了 DAGM 数据集来训练和测试模型。我们创建了一个包含三个卷积层和两个全连接层的神经网络,并使用了 relu 激活函数和二进制交叉熵损失函数来训练模型。训练数据和测试数据都以 numpy 数组的形式加载,并保存在 npy 文件中。在训练过程中,我们使用了验证数据来检查模型的泛化能力。最后,我们评估了模型的准确性,并绘制了训练和验证准确率曲线。请注意,这只是一个简单的示例代码,实际上您需要根据您的具体问题来调整模型的架构和参数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值