資源簡介
快速搭建垃圾分類模型:
使用inception快速搭建的圖像分類模型,目前支持1000類識(shí)別。從圖像中識(shí)別出類別后,再通過textcnn模型對(duì)垃圾類別進(jìn)行映射,最終輸出垃圾的類別。
注:垃圾類別是以上海分類標(biāo)準(zhǔn)。
代碼片段和文件信息
#?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
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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.me
?????目錄???????????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個(gè)文件信息
評(píng)論
共有 條評(píng)論