TensorFlow实战,BelgiumTS交通数识别(二)(读取数据和显示图像)

## 显示所有类别的图像

import matplotlib.pyplot as plt
from load import*

###   #Get the unique labels#
unique_labels = set(labels)#set() 函数是python内置函数的其中一个,属于比较基础的函数。
                          # 创建一个无序不重复元素集,可进行关系测试,删除重复数据,
                          # 还可以计算交集、差集、并集等。

### #Initialize the figure
plt.figure(figsize=(15, 15))#指定figure长宽

###  #Set a counter
i = 1

###  #For each unique label,
for label in unique_labels:
    # You pick the first image for each label
    image = images28[labels.index(label)]#.index检测字符串中是否包含子字符串 labels
                                         #如果包含子字符串返回开始的索引值
    #  #Define 64 subplots

    plt.subplot(7, 9, i)#7行9列排列图,i为编号

    # Don't include axes
    plt.axis('off')

    # Add a title to each subplot
    plt.title("Label {} ({})".format(label, labels.count(label)))#.count统计某一类出现的个数
                                                                   #label、labels.count(label)分别
                                                                   #对应{0} ({1})位置,详见str.format()
                                                                   #用法
    # Add 1 to the counter
    i += 1

    # And you plot this first image
    plt.imshow(image)#显示热力图

###  #Show the plot
plt.show()

默认显示热力图

后续更新代码

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值