Skip to content

Commit

Permalink
correctly parse and upload jsonl annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylampada committed Sep 13, 2024
1 parent a220d8b commit 7572e67
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
6 changes: 3 additions & 3 deletions roboflow/util/folderparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ def _filterIndividualAnnotations(image, annotation, format, imgRefMap, annotatio
else:
return None
elif format == "jsonl":
imgLines = [line for line in parsed if line["image"] == image["name"]]
if imgLines:
_annotation = {"name": "annotation.jsonl", "rawText": json.dumps(imgLines)}
jsonlLines = [json.dumps(line) for line in parsed if line["image"] == image["name"]]
if jsonlLines:
_annotation = {"name": "annotation.jsonl", "rawText": "\n".join(jsonlLines)}
return _annotation
return None

Expand Down
3 changes: 2 additions & 1 deletion tests/manual/debugme.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
# f"import {thisdir}/data/cultura-pepino-yolov8_voc -w wolfodorpythontests -p yellow-auto -c 100".split() # noqa: E501 // docs
# f"import {thisdir}/data/cultura-pepino-yolov5pytorch -w wolfodorpythontests -p yellow-auto -c 100 -n papaiasso".split() # noqa: E501 // docs
# f"import {thisdir}/../datasets/mosquitos -w wolfodorpythontests -p yellow-auto -n papaiasso".split() # noqa: E501 // docs
f"deployment list".split() # noqa: E501 // docs
# f"deployment list".split() # noqa: E501 // docs
f"import -w tonyprivate -p meh-plvrv {thisdir}/../datasets/paligemma/".split() # noqa: E501 // docs
)
args.func(args)
16 changes: 2 additions & 14 deletions tests/util/test_folderparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,8 @@ def test_paligemma_format(self):
testImagePath = "/dataset/de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg"
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
assert testImage["annotationfile"]["name"] == "annotation.jsonl"
expected = json.dumps(
[
{
"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg",
"prefix": "Which sector had the highest ROI in 2013?",
"suffix": "Retail",
},
{
"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg",
"prefix": "Which sector had the highest ROI in 2014?",
"suffix": "Electronics",
},
]
)
expected = """{"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg", "prefix": "Which sector had the highest ROI in 2013?", "suffix": "Retail"}
{"image": "de48275e1ff70fab78bee31e09fc896d_png.rf.01a97b1ad053aa1e6525ac0451cee8b7.jpg", "prefix": "Which sector had the highest ROI in 2014?", "suffix": "Electronics"}"""
assert testImage["annotationfile"]["rawText"] == expected


Expand Down

0 comments on commit 7572e67

Please sign in to comment.