@@ -1361,15 +1361,21 @@ class CityScapesMockData:
1361
1361
def generate (cls , root , config ):
1362
1362
1363
1363
mode = config .mode .capitalize ()
1364
- split = config .split
1364
+ req_split = config .split
1365
1365
1366
- if split in ["train" , "train_extra" ]:
1366
+ if req_split in ["train" , "train_extra" ]:
1367
1367
cities = ["bochum" , "bremen" , "jena" ]
1368
1368
num_samples = 3
1369
1369
else :
1370
1370
cities = ["frankfurt" , "munster" ]
1371
1371
num_samples = 2
1372
1372
1373
+ if mode == "Fine" :
1374
+ splits = ["train" , "test" , "val" ]
1375
+ else :
1376
+ splits = ["train" , "train_extra" , "val" ]
1377
+
1378
+ # Below values are just example values and not some special values
1373
1379
polygon_target = {
1374
1380
"imgHeight" : 1024 ,
1375
1381
"imgWidth" : 2048 ,
@@ -1400,37 +1406,44 @@ def generate(cls, root, config):
1400
1406
1401
1407
gt_dir = root / f"gt{ mode } "
1402
1408
1403
- for city in cities :
1409
+ for split in splits :
1410
+ for city in cities :
1411
+
1412
+ def make_images (file_name_fn , size = 10 ):
1413
+ create_image_folder (
1414
+ root = gt_dir / split ,
1415
+ name = city ,
1416
+ file_name_fn = file_name_fn ,
1417
+ size = size ,
1418
+ num_examples = num_samples ,
1419
+ )
1420
+
1421
+ make_images (lambda idx : f"{ city } _000000_{ idx :06d} _gt{ mode } _instanceIds.png" )
1422
+ make_images (lambda idx : f"{ city } _000000_{ idx :06d} _gt{ mode } _labelIds.png" )
1423
+ make_images (lambda idx : f"{ city } _000000_{ idx :06d} _gt{ mode } _color.png" , size = (4 , 10 , 10 ))
1404
1424
1405
- def make_images (file_name_fn , size = 10 ):
1425
+ for idx in range (num_samples ):
1426
+ polygon_target_name = gt_dir / split / city / f"{ city } _000000_{ idx :06d} _gt{ mode } _polygons.json"
1427
+ with open (polygon_target_name , "w" ) as outfile :
1428
+ json .dump (polygon_target , outfile )
1429
+
1430
+ # Create leftImg8bit folder
1431
+ for city in cities :
1406
1432
create_image_folder (
1407
- root = gt_dir / split ,
1433
+ root = root / "leftImg8bit" / split ,
1408
1434
name = city ,
1409
- file_name_fn = file_name_fn ,
1410
- size = size ,
1435
+ file_name_fn = lambda idx : f"{ city } _000000_{ idx :06d} _leftImg8bit.png" ,
1411
1436
num_examples = num_samples ,
1412
1437
)
1413
1438
1414
- make_images (lambda idx : f"{ city } _000000_{ idx :06d} _gt{ mode } _instanceIds.png" )
1415
- make_images (lambda idx : f"{ city } _000000_{ idx :06d} _gt{ mode } _labelIds.png" )
1416
- make_images (lambda idx : f"{ city } _000000_{ idx :06d} _gt{ mode } _color.png" , size = (4 , 10 , 10 ))
1417
-
1418
- for idx in range (num_samples ):
1419
- polygon_target_name = gt_dir / split / city / f"{ city } _000000_{ idx :06d} _gt{ mode } _polygons.json"
1420
- with open (polygon_target_name , "w" ) as outfile :
1421
- json .dump (polygon_target , outfile )
1439
+ for zip_name , folder_name in cls ._ARCHIVE_NAMES [(mode , req_split )]:
1440
+ # Create dummy README and license.txt
1441
+ for filename in ["README" , "license.txt" ]:
1442
+ with (root / filename ).open ("w" ) as handler :
1443
+ handler .write ("Content\n " )
1422
1444
1423
- # Create leftImg8bit folder
1424
- for city in cities :
1425
- create_image_folder (
1426
- root = root / "leftImg8bit" / split ,
1427
- name = city ,
1428
- file_name_fn = lambda idx : f"{ city } _000000_{ idx :06d} _leftImg8bit.png" ,
1429
- num_examples = num_samples ,
1430
- )
1445
+ make_zip (root , zip_name , folder_name , root / "README" , root / "license.txt" )
1431
1446
1432
- for zip_name , folder_name in cls ._ARCHIVE_NAMES [(mode , split )]:
1433
- make_zip (root , zip_name , folder_name )
1434
1447
return len (cities ) * num_samples
1435
1448
1436
1449
0 commit comments