資源簡介
prepro.py
代碼片段和文件信息
import?tensorflow?as?tf
import?os
import?random
import?numpy?as?np
from?scipy?import?misc
source_file?=?“D:“??#?原始文件地址
target_file?=?“D:“??#?修改后的文件地址
num?=?5??#?產生圖片次數
if?not?os.path.exists(target_file):??#?如果不存在target_file,則創造一個
????os.makedirs(target_file)
file_list?=?os.listdir(source_file)??#?讀取原始文件的路徑
#print(len(file_list))
tf.set_random_seed(666)
for?n?in?range(1000):
????image_raw_data?=?tf.gfile.FastGFile(source_file?+?file_list[n]?“rb“).read()
????with?tf.Session()?as?sess:
????????#a?=?1000
????????????#a?=?random.randint(1?max_random)??#?隨機數字區間
????????????#??#?讀取圖片
????????????print(“正在處理第“n“張圖片:“file_list[n])
????????????image_data?=?tf.image.decode_image(image_raw_data?channels=3)
????????????for?i?
- 上一篇:爬取51job網站招聘信息
- 下一篇:python一加云相冊批量爬蟲
評論
共有 條評論