Skip to content

Commit d842a1b

Browse files
committed
remove unecessary "parsed" attribute
1 parent 9b418f2 commit d842a1b

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

roboflow/util/folderparser.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,17 @@ def _filterIndividualAnnotations(image, annotation, format):
126126
"iscrowd": 0,
127127
}
128128
imgReference = imgReferences[0]
129-
_annotation = {
130-
"name": "annotation.coco.json",
131-
"parsedType": "coco",
132-
"parsed": {
129+
_annotation = {"name": "annotation.coco.json"}
130+
_annotation["rawText"] = json.dumps(
131+
{
133132
"info": parsed["info"],
134133
"licenses": parsed["licenses"],
135134
"categories": parsed["categories"],
136135
"images": [imgReference],
137136
"annotations": [a for a in parsed["annotations"] if a["image_id"] == imgReference["id"]]
138137
or [fake_annotation],
139-
},
140-
}
141-
_annotation["rawText"] = json.dumps(_annotation["parsed"])
138+
}
139+
)
142140
return _annotation
143141
elif format == "createml":
144142
imgReferences = [i for i in parsed if i["image"] == image["name"]]
@@ -148,8 +146,6 @@ def _filterIndividualAnnotations(image, annotation, format):
148146
imgReference = imgReferences[0]
149147
_annotation = {
150148
"name": "annotation.createml.json",
151-
"parsedType": "createml",
152-
"parsed": [imgReference],
153149
"rawText": json.dumps([imgReference]),
154150
}
155151
return _annotation
@@ -159,11 +155,6 @@ def _filterIndividualAnnotations(image, annotation, format):
159155
headers = parsed["headers"]
160156
_annotation = {
161157
"name": "annotation.csv",
162-
"parsedType": "csv",
163-
"parsed": {
164-
"headers": headers,
165-
"lines": imgLines,
166-
},
167158
"rawText": "".join([headers] + imgLines),
168159
}
169160
return _annotation

tests/util/test_folderparser.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ def test_parse_sharks_coco(self):
1818
parsed = folderparser.parsefolder(sharksfolder)
1919
testImagePath = "/train/sharks_mp4-20_jpg.rf.90ba2e8e9ca0613f71359efb7ed48b26.jpg"
2020
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
21-
assert len(testImage["annotationfile"]["parsed"]["annotations"]) == 5
21+
assert len(json.loads(testImage["annotationfile"]["rawText"])["annotations"]) == 5
2222

2323
def test_parse_sharks_createml(self):
2424
sharksfolder = f"{thisdir}/../datasets/sharks-tiny-createml"
2525
parsed = folderparser.parsefolder(sharksfolder)
2626
testImagePath = "/train/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.jpg"
2727
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
28-
assert len(testImage["annotationfile"]["parsed"]) == 1
29-
imgReference = testImage["annotationfile"]["parsed"][0]
28+
imgParsedAnnotations = json.loads(testImage["annotationfile"]["rawText"])
29+
assert len(imgParsedAnnotations) == 1
30+
imgReference = imgParsedAnnotations[0]
3031
assert len(imgReference["annotations"]) == 5
3132

3233
def test_parse_sharks_yolov9(self):
@@ -44,10 +45,9 @@ def test_parse_mosquitos_csv(self):
4445
testImagePath = "/train_10308.jpeg"
4546
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
4647
assert testImage["annotationfile"]["name"] == "annotation.csv"
47-
headers = testImage["annotationfile"]["parsed"]["headers"]
48-
lines = testImage["annotationfile"]["parsed"]["lines"]
49-
assert headers == "img_fName,img_w,img_h,class_label,bbx_xtl,bbx_ytl,bbx_xbr,bbx_ybr\n"
50-
assert lines == ["train_10308.jpeg,1058,943,japonicus/koreicus,28,187,908,815\n"]
48+
expected = "img_fName,img_w,img_h,class_label,bbx_xtl,bbx_ytl,bbx_xbr,bbx_ybr\n"
49+
expected += "train_10308.jpeg,1058,943,japonicus/koreicus,28,187,908,815\n"
50+
assert testImage["annotationfile"]["rawText"] == expected
5151

5252

5353
def _assertJsonMatchesFile(actual, filename):

0 commit comments

Comments
 (0)