资源简介

快速搭建垃圾分类模型: 使用inception快速搭建的图像分类模型,目前支持1000类识别。从图像中识别出类别后,再通过textcnn模型对垃圾类别进行映射,最终输出垃圾的类别。 注:垃圾类别是以上海分类标准。

资源截图

代码片段和文件信息

# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License Version 2.0 (the “License“);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing software
# distributed under the License is distributed on an “AS IS“ BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

“““Simple image classification with Inception.
Run image classification with Inception trained on ImageNet 2012 Challenge data
set.
This program creates a graph from a saved GraphDef protocol buffer
and runs inference on an input JPEG image. It outputs human readable
strings of the top 5 predictions along with their probabilities.
Change the --image_file argument to any jpg image to compute a
classification of that image.
Please see the tutorial and website for a detailed description of how
to use this script to perform image recognition.
https://tensorflow.org/tutorials/image_recognition/
“““

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import argparse
import os.path
import re
import sys
import tarfile

import numpy as np
from six.moves import urllib
import tensorflow as tf

FLAGS = None

# pylint: disable=line-too-long
DATA_URL = ‘http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz‘
# pylint: enable=line-too-long


class NodeLookup(object):
  “““Converts integer node ID‘s to human readable labels.“““

  def __init__(self 
                uid_chinese_lookup_path 
                model_dir 
                label_lookup_path=None
                uid_lookup_path=None):
    if not label_lookup_path:
      label_lookup_path = os.path.join(
          model_dir ‘imagenet_2012_challenge_label_map_proto.pbtxt‘)
    if not uid_lookup_path:
      uid_lookup_path = os.path.join(
          model_dir ‘imagenet_synset_to_human_label_map.txt‘)
    #self.node_lookup = self.load(label_lookup_path uid_lookup_path)
    self.node_lookup = self.load_chinese_map(uid_chinese_lookup_path)
    

  def load(self label_lookup_path uid_lookup_path):
    “““Loads a human readable English name for each softmax node.
    Args:
      label_lookup_path: string UID to integer node ID.
      uid_lookup_path: string UID to human-readable string.
    Returns:
      dict from integer node ID to human-readable string.
    “““
    if not tf.gfile.Exists(uid_lookup_path):
      tf.logging.fatal(‘File does not exist %s‘ uid_lookup_path)
    if not tf.gfile.Exists(label_lookup_path):
      tf.logging.fatal(‘File does not exist %s‘ label_lookup_path)

    # Loads mapping from string UID to human-readable string

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-07-06 10:03  rafuse_recognize\
     文件        1731  2019-07-06 10:02  rafuse_recognize\rafuse.py
     文件        1246  2019-07-06 10:03  rafuse_recognize\readme.md
     文件        8636  2019-07-06 09:52  rafuse_recognize\classify_image.py
     目录           0  2019-07-06 08:41  rafuse_recognize\runs\
     目录           0  2019-07-06 03:06  rafuse_recognize\img\
     文件      216613  2019-07-06 01:22  rafuse_recognize\img\2.png
     文件       75388  2019-07-06 01:17  rafuse_recognize\img\1.png
     目录           0  2019-07-06 08:39  rafuse_recognize\data\
     文件         346  2019-07-06 08:31  rafuse_recognize\data\valid_data.txt
     文件       24223  2019-07-06 06:19  rafuse_recognize\data\imagenet_2012_challenge_label_chinese_map.pbtxt
     文件       64986  2019-07-06 03:13  rafuse_recognize\data\imagenet_2012_challenge_label_map_proto.pbtxt
     文件      741401  2019-07-06 03:07  rafuse_recognize\data\imagenet_synset_to_human_label_map.txt
     文件        1544  2019-07-06 07:02  rafuse_recognize\data\train_data.txt
     文件     4131771  2017-08-25 01:45  rafuse_recognize\data\word2vec.bin
     目录           0  2019-07-06 09:52  rafuse_recognize\__pycache__\
     文件        6763  2019-07-06 09:52  rafuse_recognize\__pycache__\classify_image.cpython-35.pyc
     目录           0  2019-07-06 09:17  rafuse_recognize\textcnn\
     文件        4125  2019-07-06 09:01  rafuse_recognize\textcnn\text_cnn.py
     文件        9948  2019-07-06 08:41  rafuse_recognize\textcnn\train.py
     文件        2726  2019-07-06 09:15  rafuse_recognize\textcnn\predict.py
     文件         459  2019-07-06 09:17  rafuse_recognize\textcnn\README.md
     文件        3816  2019-07-06 08:39  rafuse_recognize\textcnn\eval.py
     文件        4352  2019-07-06 07:35  rafuse_recognize\textcnn\data_input_helper.py
     目录           0  2019-07-06 08:42  rafuse_recognize\runs\checkpoints\
     文件         335  2019-07-06 08:42  rafuse_recognize\runs\checkpoints\checkpoint
     文件        1115  2019-07-06 08:42  rafuse_recognize\runs\checkpoints\model-2000.index
     文件    13993020  2019-07-06 08:42  rafuse_recognize\runs\checkpoints\model-2000.data-00000-of-00001
     文件     4189170  2019-07-06 08:42  rafuse_recognize\runs\checkpoints\model-2000.meta
     目录           0  2019-07-06 09:42  rafuse_recognize\textcnn\__pycache__\
     文件        2781  2019-07-06 09:42  rafuse_recognize\textcnn\__pycache__\predict.cpython-35.pyc
............此处省略2个文件信息

评论

共有 条评论