-
大小: 9KB文件类型: .rar金币: 2下载: 0 次发布日期: 2021-06-14
- 语言: 其他
- 标签: 遥感 深度学习 Tensorflow cnn
资源简介
遥感影像场景识别—含有代码数据训练模型结果-亲测有效

代码片段和文件信息
# 将原始图片转换成需要的大小,并将其保存
# ========================================================================================
import os
import tensorflow as tf
from PIL import Image
# 原始图片的存储位置
orig_picture = ‘C:/Users/xyk/Desktop/NWPU-RESISC45/NWPU-RESISC45/‘
# 生成图片的存储位置
gen_picture = ‘C:/Users/xyk/Desktop/NWPU-RESISC45/result‘
# 需要的识别类型
classes = {‘bridge‘ ‘forest‘ ‘lake‘ ‘railway‘‘river‘‘runway‘}
# 样本总数
num_samples = 3600
# 制作TFRecords数据
def create_record():
writer = tf.python_io.TFRecordWriter(“remote_train.tfrecords“)
for index name in enumerate(classes):
class_path = orig_picture + “/“ + name + “/“
for img_name in os.listdir(class_path):
img_path = class_path + img_name
img = Image.open(img_path)
img = img.resize((256 256)) # 设置需要转换的图片大小
img_raw = img.tobytes() # 将图片转化为原生bytes
# print(“image is n“)
print(indeximg_raw)
example = tf.train.Example(
features=tf.train.Features(feature={
“label“: tf.train.Feature(int64_list=tf.train.Int64List(value=[index]))
‘img_raw‘: tf.train.Feature(bytes_list=tf.train.BytesList(value=[img_raw]))
}))
writer.write(example.SerializeToString())
writer.close()
# =======================================================================================
def read_and_decode(filename):
# 创建文件队列不限读取的数量
filename_queue = tf.train.string_input_producer([filename])
# create a reader from file queue
reader = tf.TFRecordReader()
# reader从文件队列中读入一个序列化的样本
_ serialized_example = reader.read(filename_queue)
# get feature from serialized example
# 解析符号化的样本
features = tf.parse_single_example(
serialized_example
features={
‘label‘: tf.FixedLenFeature([] tf.int64)
‘img_raw‘: tf.FixedLenFeature([] tf.string)
})
label = features[‘label‘]
img = features[‘img_raw‘]
img = tf.decode_raw(img tf.uint8)
img = tf.reshape(img [256 256 3])
# img = tf.cast(img tf.float32) * (1. / 255) - 0.5
label = tf.cast(label tf.int32)
return img label
# =======================================================================================
if __name__ == ‘__main__‘:
create_record()
batch = read_and_decode(‘remote_train.tfrecords‘)
init_op = tf.group(tf.global_variables_initializer() tf.local_variables_initializer())
with tf.Session() as sess: # 开始一个会话
sess.run(init_op)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(num_samples):
example lab = sess.run(batch) # 在会话中取出image和label
img = Image.fromarray(example ‘RGB‘) # 这里Image是之前提到的
img.save(gen_picture + ‘/‘ + str(i) + ‘samples‘ + str(lab) + ‘.jpg‘) # 存下图片;注意cwd后边加上‘/’
print(example lab)
coord.request_stop()
coord.join(t
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3311 2018-09-28 11:11 遥感影像场景识别—内涵数据训练模型结果-亲测有效\tf_record1.py
文件 4955 2018-09-26 15:19 遥感影像场景识别—内涵数据训练模型结果-亲测有效\tf_record2.py
文件 7167 2018-09-27 15:06 遥感影像场景识别—内涵数据训练模型结果-亲测有效\tf_record3.py
文件 3200 2018-09-27 19:25 遥感影像场景识别—内涵数据训练模型结果-亲测有效\tf_record4.py
文件 3577 2018-09-28 11:22 遥感影像场景识别—内涵数据训练模型结果-亲测有效\tf_record5.py
文件 64 2018-09-28 21:53 遥感影像场景识别—内涵数据训练模型结果-亲测有效\训练模型.txt
目录 0 2018-09-28 21:52 遥感影像场景识别—内涵数据训练模型结果-亲测有效
----------- --------- ---------- ----- ----
22274 7
- 上一篇:VFSEditor.exe
- 下一篇:顺丰快递数据库设计
相关资源
- 遥感图像几何校正模型探讨
- 印度泰米尔纳德邦Noyyal流域利用GIS和
- 广联达6.0写锁包,2020年11月最新
- TensorFlow1.4 官方手册
- 机器学习个人笔记完整版v5.2-A4打印版
- 深度学习卷积神经网络可检测和分类
- 遥感技术在地质灾害中的应用
- 遥感原理与应用.rar
- SPOT-5影像在安徽省矿山地质环境遥感
- 浅析遥感图像解译在矿区公路建设中
- GAN对抗式生成网络的应用:从图片上
- [en]深度学习[Deep Learning: Adaptive Compu
- img格式遥感图像读取代码
- IDL+ENVI开发多光谱遥感图像DN值求辐亮
- 李宏毅-机器学习(视频2017完整)
- 吴恩达深度学习第一课第四周作业及
- 机器学习深度学习 PPT
- 麻省理工:深度学习介绍PPT-1
- Wikipedia机器学习迷你电子书之四《D
- 深度学习在遥感中的应用综述
- 深度学习数据集标注
- 深度学习算法实践源码-吴岸城
- MSCNN_dehaze.rar
- 基于双向LSTM+tensorflow中文分词
- 李宏毅深度学习ppt
- SSD目标检测算法论文-英文原版
- 台湾李宏毅教授深度学习讲义 pdf
- 基于深度学习实现人脸识别包含模型
- 深度学习与PyTorch-代码和PPT.zip
- 测试工程源码1(一种基于深度学习的
评论
共有 条评论