-
大小: 133KB文件类型: .zip金币: 2下载: 1 次发布日期: 2021-05-14
- 语言: Python
- 标签:
资源简介
手势识别使用在TensorFlow中卷积神经网络实现
代码片段和文件信息
# The architecture is inspired by LeNet-5 (LeCun 1998)
import os
import tensorflow as tf
# Parameter
IMAGE_HEIGHT = 240
IMAGE_WIDTH = 320
BATCH_SIZE = 5
NUM_EPOCHS = 2
NUM_CLASS = 5
NUM_CHANNELS = 3
CONV1_FILTER_SIZE = 32
CONV1_FILTER_COUNT = 4
CONV2_FILTER_SIZE = 16
CONV2_FILTER_COUNT = 6
HIDDEN_layer_SIZE = 400
def read_images(data_dir):
pattern = os.path.join(data_dir ‘*.png‘)
filenames = tf.train.match_filenames_once(pattern name=‘list_files‘)
queue = tf.train.string_input_producer(
filenames
num_epochs=NUM_EPOCHS
shuffle=True
name=‘queue‘)
reader = tf.WholeFileReader()
filename content = reader.read(queue name=‘read_image‘)
filename = tf.Print(
filename
data=[filename]
message=‘loading: ‘)
filename_split = tf.string_split([filename] delimiter=‘/‘)
label_id = tf.string_to_number(tf.substr(filename_split.values[1]
0 1) out_type=tf.int32)
label = tf.one_hot(
label_id-1
5
on_value=1.0
off_value=0.0
dtype=tf.float32)
img_tensor = tf.image.decode_png(
content
dtype=tf.uint8
channels=3
name=‘img_decode‘)
# Preprocess the image Performs random transformations
# Random flip
img_tensor_flip = tf.image.random_flip_left_right(img_tensor)
# Random brightness
img_tensor_bri = tf.image.random_brightness(img_tensor_flip
max_delta=0.2)
# Per-image scaling
img_tensor_std = tf.image.per_image_standardization(img_tensor_bri)
min_after_dequeue = 1000
capacity = min_after_dequeue + 3 * BATCH_SIZE
example_batch label_batch = tf.train.shuffle_batch(
[img_tensor_std label]
batch_size=BATCH_SIZE
shapes=[(IMAGE_HEIGHT IMAGE_WIDTH NUM_CHANNELS) (NUM_CLASS)]
capacity=capacity
min_after_dequeue=min_after_dequeue
name=‘train_shuffle‘)
return example_batch label_batch
# ‘images‘ is a 4-D tensor with the shape:
# [n_batch img_height img_width n_channel]
def inference(images):
# Convolutional layer 1
with tf.name_scope(‘conv1‘):
W = tf.Variable(
tf.truncated_normal(
shape=(
CONV1_FILTER_SIZE
CONV1_FILTER_SIZE
NUM_CHANNELS
CONV1_FILTER_COUNT)
dtype=tf.float32
stddev=5e-2)
name=‘weights‘)
b = tf.Variable(
tf.zeros(
shape=(CONV1_FILTER_COUNT)
dtype=tf.float32)
name=‘biases‘)
conv = tf.nn.conv2d(
input=images
filter=W
strides=(1 1 1 1)
padding=‘SAME‘
name=‘convolutional‘)
conv_bias = tf.nn.bias_add(conv b)
conv_act = tf.nn.relu(
features=conv_bias
name=‘activation‘)
poo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-02-25 07:21 hsr-master\
文件 569 2017-02-25 07:21 hsr-master\README.md
文件 138259 2017-02-25 07:21 hsr-master\hsr-eval.png
文件 6113 2017-02-25 07:21 hsr-master\hsr.py
文件 2129 2017-02-25 07:21 hsr-master\train.py
相关资源
- Python-DeepMoji模型的pyTorch实现
- Python-使用DeepFakes实现YouTube视频自动换
- Python-一系列高品质的动漫人脸数据集
- Python-Insightface人脸检测识别的最小化
- Python-自然场景文本检测PSENet的一个
- Python-在特征金字塔网络FPN的Pytorch实现
- Python-PyTorch实时多人姿态估计项目的实
- Python-用PyTorch10实现FasterRCNN和MaskRCNN比
- Python-心脏核磁共振MRI图像分割
- Python-基于YOLOv3的行人检测
- Python-RLSeq2Seq用于SequencetoSequence模型的
- Python-PyTorch对卷积CRF的参考实现
- Python-高效准确的EAST文本检测器的一个
- Python-pytorch实现的人脸检测和人脸识别
- Python-UNet用于医学图像分割的嵌套UN
- Python-TensorFlow弱监督图像分割
- Python-基于tensorflow实现的用textcnn方法
- Python-Keras实现Inceptionv4InceptionResnetv1和
- Python-pytorch中文手册
- Python-FastSCNN的PyTorch实现快速语义分割
- Python-滑动窗口高分辨率显微镜图像分
- Python-使用MovieLens数据集训练的电影推
- Python-机器学习驱动的Web应用程序防火
- Python-subpixel利用Tensorflow的一个子像素
-
Python-汉字的神经风格转移Neuralst
y - Python-神经网络模型能够从音频演讲中
- Python-深度增强学习算法的PyTorch实现策
- Python-基于深度学习的语音增强使用
- Python-基于知识图谱的红楼梦人物关系
- Python-STGAN用于图像合成的空间变换生
评论
共有 条评论