91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

遙感影像場(chǎng)景識(shí)別—含有代碼數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效

資源截圖

代碼片段和文件信息

#?將原始圖片轉(zhuǎn)換成需要的大小,并將其保存
#?========================================================================================
import?os
import?tensorflow?as?tf
from?PIL?import?Image

#?原始圖片的存儲(chǔ)位置
orig_picture?=?‘C:/Users/xyk/Desktop/NWPU-RESISC45/NWPU-RESISC45/‘

#?生成圖片的存儲(chǔ)位置
gen_picture?=?‘C:/Users/xyk/Desktop/NWPU-RESISC45/result‘

#?需要的識(shí)別類型
classes?=?{‘bridge‘?‘forest‘?‘lake‘?‘railway‘‘river‘‘runway‘}

#?樣本總數(shù)
num_samples?=?3600


#?制作TFRecords數(shù)據(jù)
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))??#?設(shè)置需要轉(zhuǎn)換的圖片大小
????????????img_raw?=?img.tobytes()??#?將圖片轉(zhuǎn)化為原生bytes
????????????#?print(“image?is?n“)
????????????print(indeximg_raw)
????????????example?=?tf.train.Example(
????????????????features=tf.train.Features(feature={
????????????????????“l(fā)abel“:?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):
????#?創(chuàng)建文件隊(duì)列不限讀取的數(shù)量
????filename_queue?=?tf.train.string_input_producer([filename])
????#?create?a?reader?from?file?queue
????reader?=?tf.TFRecordReader()
????#?reader從文件隊(duì)列中讀入一個(gè)序列化的樣本
????_?serialized_example?=?reader.read(filename_queue)
????#?get?feature?from?serialized?example
????#?解析符號(hào)化的樣本
????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:??#?開始一個(gè)會(huì)話
????????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)??#?在會(huì)話中取出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

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????3311??2018-09-28?11:11??遙感影像場(chǎng)景識(shí)別—內(nèi)涵數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效\tf_record1.py

?????文件???????4955??2018-09-26?15:19??遙感影像場(chǎng)景識(shí)別—內(nèi)涵數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效\tf_record2.py

?????文件???????7167??2018-09-27?15:06??遙感影像場(chǎng)景識(shí)別—內(nèi)涵數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效\tf_record3.py

?????文件???????3200??2018-09-27?19:25??遙感影像場(chǎng)景識(shí)別—內(nèi)涵數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效\tf_record4.py

?????文件???????3577??2018-09-28?11:22??遙感影像場(chǎng)景識(shí)別—內(nèi)涵數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效\tf_record5.py

?????文件?????????64??2018-09-28?21:53??遙感影像場(chǎng)景識(shí)別—內(nèi)涵數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效\訓(xùn)練模型.txt

?????目錄??????????0??2018-09-28?21:52??遙感影像場(chǎng)景識(shí)別—內(nèi)涵數(shù)據(jù)訓(xùn)練模型結(jié)果-親測(cè)有效

-----------?---------??----------?-----??----

????????????????22274????????????????????7


評(píng)論

共有 條評(píng)論

相關(guān)資源