77thisdir = os .path .dirname (os .path .abspath (__file__ ))
88
99
10+ def patch_sep (filename ):
11+ return filename .replace ("/" , os .sep )
12+
13+
1014def _find_test_image (image , images ):
11- image = image .replace ("/" , os .sep )
12- return next (i for i in images if i ["file" ] == image )
15+ return next (i for i in images if i ["file" ] == patch_sep (image ))
1316
1417
1518class TestFolderParser (unittest .TestCase ):
@@ -22,14 +25,12 @@ def test_parse_sharks_coco(self):
2225 sharksfolder = f"{ thisdir } /../datasets/sharks-tiny-coco"
2326 parsed = folderparser .parsefolder (sharksfolder )
2427 testImagePath = "/train/sharks_mp4-20_jpg.rf.90ba2e8e9ca0613f71359efb7ed48b26.jpg"
25- print ("PARSED" , parsed ["images" ])
2628 testImage = _find_test_image (testImagePath , parsed ["images" ])
2729 assert len (json .loads (testImage ["annotationfile" ]["rawText" ])["annotations" ]) == 5
2830
2931 def test_parse_sharks_createml (self ):
3032 sharksfolder = f"{ thisdir } /../datasets/sharks-tiny-createml"
3133 parsed = folderparser .parsefolder (sharksfolder )
32- print ("PARSED" , parsed ["images" ])
3334 testImagePath = "/train/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.jpg"
3435 testImage = _find_test_image (testImagePath , parsed ["images" ])
3536 imgParsedAnnotations = json .loads (testImage ["annotationfile" ]["rawText" ])
@@ -43,7 +44,7 @@ def test(sharksfolder):
4344 testImagePath = "/train/images/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.jpg"
4445 testImage = _find_test_image (testImagePath , parsed ["images" ])
4546 expectAnnotationFile = "/train/labels/sharks_mp4-20_jpg.rf.5359121123e86e016401ea2731e47949.txt"
46- assert testImage ["annotationfile" ]["file" ] == expectAnnotationFile
47+ assert testImage ["annotationfile" ]["file" ] == patch_sep ( expectAnnotationFile )
4748 assert testImage ["annotationfile" ]["labelmap" ] == {0 : "fish" , 1 : "primary" , 2 : "shark" }
4849
4950 test (f"{ thisdir } /../datasets/sharks-tiny-yolov9" )
0 commit comments