【发布时间】:2016-07-14 18:42:54
【问题描述】:
我正在尝试编写一个函数,在 tensorflow 中读取 json 文件。 json 文件具有以下结构:
{
"bounding_box": {
"y": 98.5,
"x": 94.0,
"height": 197,
"width": 188
},
"rotation": {
"yaw": -27.97019577026367,
"roll": 2.206029415130615,
"pitch": 0.0},
"confidence": 3.053506851196289,
"landmarks": {
"1": {
"y": 180.87722778320312,
"x": 124.47326660156205},
"0": {
"y": 178.60653686523438,
"x": 183.41931152343795},
"2": {
"y": 224.5936889648438,
"x": 141.62365722656205
}}}
我只需要边界框信息。有几个关于如何编写read_and_decode-functions的示例,我正在尝试将这些示例转换为json文件的函数,但仍有很多问题......:
def read_and_decode(filename_queue):
reader = tf.WhichKindOfReader() # ???
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
features={
'bounding_box':{
'y': tf.VarLenFeature(<whatstheproperdatatype>) ???
'x':
'height':
'width':
# I only need the bounding box... - do I need to write
# the format information for the other features...???
}
})
y=tf.decode() # decoding necessary?
x=
height=
width=
return x,y,height,width
我已经在互联网上做了几个小时的研究,但找不到任何关于如何在 tensorflow 中读取 json 的详细信息......
也许有人可以给我一个线索...
【问题讨论】:
标签: python json neural-network tensorflow