Skip to content

Commit 244938d

Browse files
authored
Merge pull request #248 from roboflow/bugfix-trailing-slash
BugFix: importing a yolo dataset with a trailing slash ignores annotations
2 parents 2a8917a + 3f1b6b3 commit 244938d

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

.devcontainer/devcontainer.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"vscode": {
99
"extensions": [
1010
"ms-python.python",
11+
"ms-python.debugpy",
1112
"ms-python.black-formatter"
1213
],
1314
"settings": {

roboflow/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from roboflow.models import CLIPModel, GazeModel # noqa: F401
1515
from roboflow.util.general import write_line
1616

17-
__version__ = "1.1.27"
17+
__version__ = "1.1.28"
1818

1919

2020
def check_key(api_key, model, notebook, num_retries=0):

roboflow/util/folderparser.py

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111

1212
def parsefolder(folder):
13+
folder = folder.strip()
14+
if folder.endswith("/"):
15+
folder = folder[:-1]
1316
if not os.path.exists(folder):
1417
raise Exception(f"folder does not exist. {folder}")
1518
files = _list_files(folder)

tests/util/test_folderparser.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,20 @@ def test_parse_sharks_createml(self):
3131
assert len(imgReference["annotations"]) == 5
3232

3333
def test_parse_sharks_yolov9(self):
34-
sharksfolder = f"{thisdir}/../datasets/sharks-tiny-yolov9"
35-
parsed = folderparser.parsefolder(sharksfolder)
36-
testImagePath = "/train/images/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.jpg"
37-
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
38-
expectAnnotationFile = "/train/labels/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.txt"
39-
assert testImage["annotationfile"]["file"] == expectAnnotationFile
40-
assert testImage["annotationfile"]["labelmap"] == {0: "fish", 1: "primary", 2: "shark"}
34+
def test(sharksfolder):
35+
parsed = folderparser.parsefolder(sharksfolder)
36+
testImagePath = "/train/images/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.jpg"
37+
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
38+
expectAnnotationFile = "/train/labels/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.txt"
39+
assert testImage["annotationfile"]["file"] == expectAnnotationFile
40+
assert testImage["annotationfile"]["labelmap"] == {0: "fish", 1: "primary", 2: "shark"}
41+
42+
test(f"{thisdir}/../datasets/sharks-tiny-yolov9")
43+
test(f"{thisdir}/../datasets/sharks-tiny-yolov9/") # this was a bug once, can you believe it?
4144

4245
def test_parse_mosquitos_csv(self):
43-
sharksfolder = f"{thisdir}/../datasets/mosquitos"
44-
parsed = folderparser.parsefolder(sharksfolder)
46+
folder = f"{thisdir}/../datasets/mosquitos"
47+
parsed = folderparser.parsefolder(folder)
4548
testImagePath = "/train_10308.jpeg"
4649
testImage = [i for i in parsed["images"] if i["file"] == testImagePath][0]
4750
assert testImage["annotationfile"]["name"] == "annotation.csv"

0 commit comments

Comments
 (0)