肉眼难辨别的裂纹该怎么检测?
作者 | 努比? ??责编 | 张文 头图 | CSDN?下载自视觉中国

images = []for url in tqdm.tqdm(df['content']):response = requests.get(url)img = Image.open(BytesIO(response.content))img = img.resize((224, 224))numpy_img = img_to_array(img)img_batch = np.expand_dims(numpy_img, axis=0)images.append(img_batch.astype('float16'))images = np.vstack(images)


vgg_conv = vgg16.VGG16(weights='imagenet', include_top=False, input_shape = (224, 224, 3))for layer in vgg_conv.layers[:-8]:layer.trainable = False
x = vgg_conv.outputx = GlobalAveragePooling2D()(x)x = Dense(2, activation="softmax")(x)model = Model(vgg_conv.input, x)model.compile(loss = "categorical_crossentropy", optimizer = optimizers.SGD(lr=0.0001, momentum=0.9), metrics=["accuracy"])

def plot_activation(img):pred = model.predict(img[np.newaxis,:,:,:])pred_class = np.argmax(pred)weights = model.layers[-1].get_weights()[0]class_weights = weights[:, pred_class]intermediate = Model(model.input,model.get_layer("block5_conv3").output)conv_output = intermediate.predict(img[np.newaxis,:,:,:])conv_output = np.squeeze(conv_output)h = int(img.shape[0]/conv_output.shape[0])w = int(img.shape[1]/conv_output.shape[1])act_maps = sp.ndimage.zoom(conv_output, (h, w, 1), order=1)out = np.dot(act_maps.reshape((img.shape[0]*img.shape[1],512)),class_weights).reshape(img.shape[0],img.shape[1])plt.imshow(img.astype('float32').reshape(img.shape[0],img.shape[1],3))plt.imshow(out, cmap='jet', alpha=0.35)plt.title('Crack' if pred_class == 1 else 'No Crack')



程序员如何避免陷入“内卷”、选择什么技术最有前景,中国开发者现状与技术趋势究竟是什么样?快来参与「2020?中国开发者大调查」,更有丰富奖品送不停!

更多精彩推荐 ?1.6 万亿参数你怕了吗?谷歌大脑语言模型速度是 T5 速度的 7 倍
?2020 ACM Fellows 名单出炉,13 名华人入选,7 名来自国内!
?再次被替代?六成应用开发不需要程序员
?除了 Docker,我们还有哪些选择?
?突发!Intel CEO 换帅,VMware CEO 将走马上任
点分享 点收藏 点点赞 点在看
关注公众号:拾黑(shiheibook)了解更多
[广告]赞助链接:
四季很好,只要有你,文娱排行榜:https://www.yaopaiming.com/
让资讯触达的更精准有趣:https://www.0xu.cn/









![37度的幼嫩 早餐分享,鸡蛋·油条,没买到豆浆[怒],需要一杯现磨豆浆。[来] ](https://imgs.knowsafe.com:8087/img/aideep/2023/8/30/8503da51ffdbc694e863c18c11ddea9c.jpg?w=250)



CSDN
关注网络尖刀微信公众号
