Given setting (train/test), generate a list of obj file names in the shapenet dataset. Args: rootpath: the root directory of the ShapeNet dataset setting: train/test num_classes: number of class num_sample_in_class: number of mesh sample in each class
(
rootpath: str,
setting: str,
num_classes: int = 3,
num_sample_in_class: int = 2,
rnd_seed: int = 987,
use_sub_classlist: bool = False,
)
| 50 | |
| 51 | |
| 52 | def get_ShapeNet_model_list( |
| 53 | rootpath: str, |
| 54 | setting: str, |
| 55 | num_classes: int = 3, |
| 56 | num_sample_in_class: int = 2, |
| 57 | rnd_seed: int = 987, |
| 58 | use_sub_classlist: bool = False, |
| 59 | ) -> list: |
| 60 | """ |
| 61 | Given setting (train/test), generate a list of obj file names in the shapenet dataset. |
| 62 | |
| 63 | Args: |
| 64 | rootpath: the root directory of the ShapeNet dataset |
| 65 | setting: train/test |
| 66 | num_classes: number of class |
| 67 | num_sample_in_class: number of mesh sample in each class |
| 68 | rnd_seed: random seed |
| 69 | use_sub_classlist: use specific class set for train/ test |
| 70 | |
| 71 | Returns: |
| 72 | a list of filenames |
| 73 | """ |
| 74 | np.random.seed(rnd_seed) |
| 75 | img_types = ('*.jpg', '*.png', '*.jpeg', '*.JPG') |
| 76 | obj_path_list = [] |
| 77 | |
| 78 | folder_list = sorted([fname for fname in os.listdir(rootpath) if os.path.isdir(os.path.join(rootpath, fname))]) |
| 79 | with open(os.path.join(rootpath, 'taxonomy.json')) as f: |
| 80 | class_json_list = json.load(f) |
| 81 | all_class_list = [(class_json['name'].split(',')[0].replace(' ', '_'), class_json['synsetId']) for class_json in |
| 82 | class_json_list if class_json['synsetId'] in folder_list] |
| 83 | # all_class_list = [ c[0].split(',')[0].replace(' ','_') for c in all_class_list ] |
| 84 | class_to_folder = dict(all_class_list) |
| 85 | """ |
| 86 | class_to_folder = dict( |
| 87 | airplane='02691156', |
| 88 | bench='02828884', |
| 89 | cabinet='02933112', |
| 90 | car='02958343', |
| 91 | chair='03001627', |
| 92 | display='03211117', |
| 93 | lamp='03636649', |
| 94 | loudspeaker='03691459', |
| 95 | rifle='04090263', |
| 96 | sofa='04256520', |
| 97 | table='04379243', |
| 98 | cellular_telephone='04401088', |
| 99 | vessel='04530566', |
| 100 | ) |
| 101 | """ |
| 102 | |
| 103 | # In other works, the first 3 classes below are split to training set and the other 10 classes are for testing |
| 104 | fixed_class = ['airplane', 'car', 'chair', 'bench', 'rifle', 'vessel', 'cabinet', 'display', 'lamp', |
| 105 | 'loudspeaker', 'sofa', 'table', 'cellular_telephone'] |
| 106 | if setting == 'train': |
| 107 | class_list = fixed_class[:3] |
| 108 | elif setting == 'test': |
| 109 | class_list = fixed_class[3:] |
no test coverage detected