使用js实现弹窗layer_show(title,url,w,h); 报错layer_show is not defined

博客提到layer_show(title,url,w,h)功能在js中定义,且引入该功能所需的js必须是第一个引入的js,围绕信息技术中前端js功能及引入规则展开。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先layer_show(title,url,w,h)功能是在个js中定义的,需要引入的js 为<script src="HUI/h-ui.admin/js/H-ui.admin.js"></script>且必须是第一个引入的js在这里插入图片描述

``` # 新增库导入 import cv2 import tensorflow as tf from tensorflow.keras.models import Model # Grad-CAM热图生成函数 def make_gradcam_heatmap(img_array, model, last_conv_layer_name, pred_index=None): grad_model = Model( [model.inputs], [model.get_layer(last_conv_layer_name).output, model.output] ) with tf.GradientTape() as tape: last_conv_layer_output, preds = grad_model(img_array) if pred_index is None: pred_index = tf.argmax(preds[0]) class_channel = preds[:, pred_index] grads = tape.gradient(class_channel, last_conv_layer_output) pooled_grads = tf.reduce_mean(grads, axis=(0, 1, 2)) last_conv_layer_output = last_conv_layer_output[0] heatmap = last_conv_layer_output @ pooled_grads[..., tf.newaxis] heatmap = tf.squeeze(heatmap) heatmap = tf.maximum(heatmap, 0) / tf.math.reduce_max(heatmap) # 归一化 return heatmap.numpy() # 获取示例图像 sample_batch = next(train_generator) sample_images = sample_batch[0][:5] # 取前5个样本 # 获取最后一层卷积层名称(根据模型结构调整) last_conv_layer_name = "conv2d_1" # 根据实际模型结构确认 # 创建热力图可视化 plt.figure(figsize=(16, 8)) for i in range(5): img = sample_images[i] img_array = np.expand_dims(img, axis=0) # 生成热力图 heatmap = make_gradcam_heatmap(img_array, model, last_conv_layer_name) # 调整热力图大小匹配原图 heatmap = cv2.resize(heatmap, (img_width, img_height)) heatmap = np.uint8(255 * heatmap) heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET) # 叠加热力图和原图 superimposed_img = cv2.addWeighted( cv2.cvtColor(np.uint8(img*255), cv2.COLOR_RGB2BGR), 0.6, heatmap, 0.4, 0 ) # 绘制结果 plt.subplot(2, 5, i+1) plt.imshow(img) plt.title("Original") plt.axis("off") plt.subplot(2, 5, i+6) plt.imshow(cv2.cvtColor(superimposed_img, cv2.COLOR_BGR2RGB)) plt.title("Heatmap") plt.axis("off") plt.tight_layout() plt.show()```Traceback (most recent call last): File “D:\建模\cnn3.py”, line 117, in <module> heatmap = make_gradcam_heatmap(img_array, model, last_conv_layer_name) File “D:\建模\cnn3.py”, line 85, in make_gradcam_heatmap [model.get_layer(last_conv_layer_name).output, model.output] File “C:\Users\29930\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\src\ops\operation.py”, line 280, in output return self._get_node_attribute_at_index(0, “output_tensors”, “output”) File “C:\Users\29930\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\src\ops\operation.py”, line 299, in _get_node_attribute_at_index raise AttributeError( AttributeError: The layer sequential has never been called and thus has no defined output… Did you mean: ‘outputs’? 解决该问题并生成一个可用的代码
最新发布
03-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值