Tensorflow学习:使用inception-v3做图像识别

本文介绍了如何在Tensorflow框架下应用预训练的inception-v3模型进行图像识别,通过实例展示了深度学习在图像识别领域的应用。
摘要由CSDN通过智能技术生成

Tensorflow学习:使用inception-v3做图像识别

import tensorflow as tf
import os
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt

'''数据预处理'''


class NodeLookup(object):
    def __init__(self):
        label_lookup_path = 'inception_model/imagenet_2012_challenge_label_map_proto.pbtxt'
        uid_lookup_path = 'inception_model/imagenet_synset_to_human_label_map.txt'
        self.node_lookup = self.load(label_lookup_path, uid_lookup_path)

    # 返回分类编号1-1000对应分类名称的映射关系
    def load(self, label_lookup_path, uid_lookup_path):

        # 加载分类字符串编号和对应分类名称的文件
        proto_as_ascii_lines = tf.gfile.GFile(uid_lookup_path).readlines()
        uid_to_human = {
   }
        # 一行一行读取数据
        for line in proto_as_ascii_lines:
            # 去掉换行符
            line = line.strip('\n')
            # 按'\t'分割
            parsed_items = line.split('\t')
            # 获取分类编号
            uid = parsed_items[0]
            # 获取分类名称
            human_string = parsed_items[1]
            # 保存编号和分类名称的映射关系
            uid_to_human[uid] = human_string

        # 加载分类字符串编号和对应分类编号1-1000的文件
        proto_as_ascii = tf.gfile.GFile
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值