标签:dwr ima classes for serial path 取图 dex pytho
1、读取图片文件
import tensorflow as tf from PIL import Image import os file_path=‘C:/Users/1/Desktop/123/‘ file_name=os.listdir(file_path) classes={‘A‘,‘B‘,‘C‘} writer=tf.python_io.TFRecordWriter(‘C:/Users/1/Desktop/fuck.tfrecords‘) for index,name in enumerate(classes): for name in file_name: img_path=file_path+name img=Image.open(img_path) img=img.resize((64,64)) img_raw=img.tobytes() print(index) 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]))})) imgg=example.SerializeToString() writer.write(imgg) writer.close()
标签:dwr ima classes for serial path 取图 dex pytho
原文地址:https://www.cnblogs.com/xiaochouk/p/8855453.html