gpt4 book ai didi

Number plate detection JSON dataset(车牌检测JSON数据集)

转载 作者:bug小助手 更新时间:2023-10-25 22:08:44 25 4
gpt4 key购买 nike



I am new to JSON. I am doing a project for Vehicle Number Plate Detection.
I have a dataset of the form:

我是JSON的新手。我正在做一个车牌检测的项目。我有一个表格的数据集:



{"content": "http://com.dataturks.a96-i23.open.s3.amazonaws.com/2c9fafb0646e9cf9016473f1a561002a/77d1f81a-bee6-487c-aff2-0efa31a9925c____bd7f7862-d727-11e7-ad30-e18a56154311.jpg.jpeg","annotation":[{"label":["number_plate"],"notes":"","points":[{"x":0.7220843672456576,"y":0.5879828326180258},{"x":0.8684863523573201,"y":0.6888412017167382}],"imageWidth":806,"imageHeight":466}],"extras":null},
{"content": "http://com.dataturks.a96-i23.open.s3.amazonaws.com/2c9fafb0646e9cf9016473f1a561002a/4eb236a3-6547-4103-b46f-3756d21128a9___06-Sanjay-Dutt.jpg.jpeg","annotation":[{"label":["number_plate"],"notes":"","points":[{"x":0.16194331983805668,"y":0.8507795100222717},{"x":0.582995951417004,"y":1}],"imageWidth":494,"imageHeight":449}],"extras":null},


There are in total 240 blocks of data.
I want to do two things with the above dataset.
Firstly,I need to download all the images from each block and secondly,need to get the values of "points" column to a text file.

总共有240个数据块。我想用上面的数据集做两件事。首先,我需要从每个块下载所有的图像,其次,需要获得“Points”列的值到一个文本文件。



I am getting problem while getting the values for the columns.

我在获取列的值时遇到了问题。



import json
jsonFile = open('Indian_Number_plates.json', 'r')
x = json.load(jsonFile)
for criteria in x['annotation']:
for key, value in criteria.iteritems():
print(key, 'is:', value)
print('')


I have written the above code to get all the values under the "annotation".
But,getting the following error

我已经编写了上面的代码来获取“注解”下的所有值。但是,得到以下错误



Traceback (most recent call last):
File "prac.py", line 13, in <module>
x = json.load(jsonFile)
File "C:\python364\Lib\json\__init__.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\python364\Lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:\python364\Lib\json\decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 394 (char 393)


Please help me for getting the values for "points" column and also for downloading the images from the link in the "content" section.

请帮助我获得“积分”栏的值,并从“内容”部分的链接下载图像。


更多回答

Dataturks has provided the instructions to convert dataturks annotations to pascal VOC format. It will download respective images and also store annotations in xml file formats that can be used to train with tensorflow objection models. dataturks.com/help/ibbx_dataturks_to_pascal_voc_format.php

Dataturks提供了将Dataturks注释转换为Pascal VOC格式的指令。它将下载各自的图像,并以可用于训练TensorFlow对象模型的XML文件格式存储注释。Dataturks.com/help/ibbx_dataturks_to_pascal_voc_format.php

优秀答案推荐

i found this answer while searching. Essentially, you can read an object, catch the exception when JSON sees an unexpected object, and then seek/reparse and build a list of objects.

我在搜索的过程中找到了这个答案。从本质上讲,您可以读取对象,在JSON看到意外对象时捕获异常,然后查找/重新解析并构建对象列表。



in Java, i'd just tell you to use Jackson and their SAX style streaming interface, as i've done that to read a list of objects formatted like this - if JSON in python has a streaming api, i'd use that instead of the exception handler workaround

在Java中,我只会告诉您使用Jackson和他们的SAX样式的流接口,因为我已经这样做了,以读取如下格式的对象列表--如果Python中的JSON有流API,我会使用它而不是异常处理解决方法



the error comes because your file contains two records or more :

出现错误是因为您的文件包含两条或更多记录:



{"content": "http://com.dataturks.a96- } ..... {"content": .....


to solve this you should reformat your json so that all the records are contained in an array :

要解决这个问题,您应该重新格式化您的json,以便所有记录都包含在一个数组中:



{ "data" :  [ {"content": "http://com.dataturks.a96- .... },{"content":... }]}


to download the images, extract the image names and urls and use requests :

要下载图像,请提取图像名称和URL并使用请求:



import requests

with open(image_name, 'wb') as handle:
response = requests.get(pic_url, stream=True)

if not response.ok:
print response

for block in response.iter_content(1024):
if not block:
break

handle.write(block)


Use this piece of code to read the JSON file with lines=True flag and then delete the extra:

使用这段代码读取带有Line=True标志的JSON文件,然后删除多余的:


df = pd.read_json(local_path,lines=True)
pd.set_option('display.max_colwidth', -1)
# delete the extras column
del df['extras']
# check the data dataframe
df.head()

更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com