用于创建tensorflow tfrecords的库

image2tfrecords的Python项目详细描述


#image2tfrecords
----


将图像转换为tfrecord以符合tensorflow最佳实践:[tensorflow doc link](https://tensorflow.google.cn/performance/performance\u guide\u input\u pipeline\u optimization)。


支持的平台

*ubuntu



*python
*python3



*tensorflow
*1.4

提供一个读取tfrecords文件并返回数据集的类,这样开发人员可以轻松地用图像构建tensorflow程序。



您可以检查"example_cifar10.py"以获取完整代码。


\*目录/tmp/cifar10廑u数据应该是这样的:
```
--train
--train.7z
模块需要以下格式的标签文件:

```
image2class_file:csv文件,其中包含每个图像文件的类名
格式:
filename,class
1.jpg,cat
2.jpg,dog
。,…
必须为csv文件提供有效的头。在tfrecord中使用头来表示数据集特定的信息。我们需要将cifar10标签文件转换为以下格式:

```
从image2tfrecords导入pandas作为pd

。image2tfrecords导入image2tfrecords


cifar10数据目录="/tmp/cifar10数据/train"
cifar10标签="/tmp/cifar10数据/train labels.csv"

对于所需格式,有1个步骤
1。将.png扩展名添加到文件名。

label_csv=pd.read_csv(cifar10_labels)
copy=false)
label_csv["id"]=label_csv["id"]+".png"


modified_label_file="/tmp/cifar10_data/train_labels_ext.csv"
label_csv.to_csv(modified_label_file,index=false)
````
新的标签文件是`/tmp/cifar10_data/train_labels_ext.csv`

\
修改的标签文件,
值大小=0.3,
测试大小=0.1,
数据集名称=cifar10"
img2tf.创建tfrecords(输出目录="/tmp/cifar10数据/tfrecords")
````
运行后,tfrecords文件将位于:`/tmp/cifar10数据/tfrecords`,it会是这样的:

````
-rw-rw-r--1 scott scott 169 12月21日10:57 cifar10-u摘要。json
-rw-rw-r--1 scott scott 2.3m 12月21日10:57 cifar10-u测试00001-of-00005。tfrecord
-rw-r--1 scott scott 2.3m 12月21日10:57 cifar10-u测试00002-of-00005。tfrecord
-rw-rw-r--1 scott scott scott scott scott2.4M 12月21日10:57 cifar10-u test_-of-00005。tfrecord
-rw-rw-r--1 scott scott 2.5m 12月21日10:57 cifar10-u test_-of-00005。tfrecord
-rw-rw-r--1 scott scott scott 2.3m 12月21日10:57 cifar10-u test_-of-00005。tfrecord
-rw-rw-r--1 scott scott scott 14M 12月21日10:56cifar10_列00001-of-00005。tfrecord
-rw-rw-r--1 scott scott 14m 12月21日10:56 cifar10_列00002-of-00005。tfrecord
-rw-rw-r--1 scott scott 15m 12月21日10:56 cifar10_列00003-of-00005。tfrecord
-rw-r--1 scott scott 15m 12月21日10:56 cifar10_列00004-of-00005.tfrecord
-rw-rw-r--1 scott scott 14m 12月21日10:57 cifar10-u列/00005.tfrecord
-rw-rw-r--1 scott scott 6.8m 12月21日10:57 cifar10-u验证/00005.tfrecord
-rw-rw-r--1 scott scott 6.9m 12月21日10:57 cifar10-u验证/00002.tfrecord
-rw-rw-r--1斯科特7.1M 12月21日10:57 CIFAR10-U验证00003-OF-00005。tfrecord
-rw-rw-r--1斯科特7.4M 12月21日10:57 CIFAR10-of-00005。tfrecord
-rw-rw-r--1斯科特6.9M 12月21日10:57 CIFAR10-of-00005。tfrecord
-rw-rw-r--1斯科特95 12月21日10:57labels.csv

```

"cifar10")
num_class=len(image_dataset.labels_df)
val_split=image_dataset.get_split("validation")
val_images,u,val_labels=batch_and_process(val_split,num_class)
````
在获取tensorflow数据集之后。最常见的做法是将其传递给"datasetdataprovider",然后从这个"datasetdataprovider"获取数据。

```
dataprovider=slim.data set\u dataprovider.datasetdataprovider(
data\u set,
common\u queue\u capacity=64,
common_queue_min=32,
num_epochs=1,shuffle=false)


image_raw,label,u=data_provider.get(['image','label','filename'])
`````



api入侵

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在一个问题被连续正确回答三次/并添加差异后,我如何将程序循环回开始   Java中未实例化的匿名类   java如何在Android中录制视频,只允许横向模式和最长时间录制时间   java从另一个活动发送实时消息   多线程java线程和互斥   java禁用Spring安全日志   JAVA伊奥。StreamCorruptedException:在与子级和父级ProcessBuilder通信时写入子级中的标准输出时,流头无效   使用Java(HttpURLConnection)对Restheart进行身份验证(对于Mongodb)   java如何解决Jenkins中的SAXParseException?   java为什么我需要mockito来测试Spring应用程序?   计算sin-cos和tan时缺乏精度(java)   java Hibernate。不同项目中相同一对一映射的不同行为   java图像滑块:如何使用JavaFX将图像放在另一个图像上   java Mockito在使用when时抛出NotAMockException   http Java servlet发送回响应