Skip to content

Commit 7572e67

Browse files
committed
correctly parse and upload jsonl annotations
1 parent a220d8b commit 7572e67

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

roboflow/util/folderparser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ def _filterIndividualAnnotations(image, annotation, format, imgRefMap, annotatio
184184
else:
185185
return None
186186
elif format == "jsonl":
187-
imgLines = [line for line in parsed if line["image"] == image["name"]]
188-
if imgLines:
189-
_annotation = {"name": "annotation.jsonl", "rawText": json.dumps(imgLines)}
187+
jsonlLines = [json.dumps(line) for line in parsed if line["image"] == image["name"]]
188+
if jsonlLines:
189+
_annotation = {"name": "annotation.jsonl", "rawText": "\n".join(jsonlLines)}
190190
return _annotation
191191
return None
192192

tests/manual/debugme.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
# f"import {thisdir}/data/cultura-pepino-yolov8_voc -w wolfodorpythontests -p yellow-auto -c 100".split() # noqa: E501 // docs
4242
# f"import {thisdir}/data/cultura-pepino-yolov5pytorch -w wolfodorpythontests -p yellow-auto -c 100 -n papaiasso".split() # noqa: E501 // docs
4343
# f"import {thisdir}/../datasets/mosquitos -w wolfodorpythontests -p yellow-auto -n papaiasso".split() # noqa: E501 // docs
44-
f"deployment list".split() # noqa: E501 // docs
44+
# f"deployment list".split() # noqa: E501 // docs
45+
f"import -w tonyprivate -p meh-plvrv {thisdir}/../datasets/paligemma/".split() # noqa: E501 // docs
4546
)
4647
args.func(args)

tests/util/test_folderparser.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,8 @@ def test_paligemma_format(self):
5858
testImagePath = "/dataset/de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg"
5959
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
6060
assert testImage["annotationfile"]["name"] == "annotation.jsonl"
61-
expected = json.dumps(
62-
[
63-
{
64-
"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg",
65-
"prefix": "Which sector had the highest ROI in 2013?",
66-
"suffix": "Retail",
67-
},
68-
{
69-
"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg",
70-
"prefix": "Which sector had the highest ROI in 2014?",
71-
"suffix": "Electronics",
72-
},
73-
]
74-
)
61+
expected = """{"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg", "prefix": "Which sector had the highest ROI in 2013?", "suffix": "Retail"}
62+
{"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg", "prefix": "Which sector had the highest ROI in 2014?", "suffix": "Electronics"}"""
7563
assert testImage["annotationfile"]["rawText"] == expected
7664

7765

0 commit comments

Comments
 (0)