MCPcopy Create free account
hub / github.com/apple/ml-pointersect / get_clean_mesh_filenames

Function get_clean_mesh_filenames

pointersect/data/dataset_helper.py:106–147  ·  view source on GitHub ↗

Get the clean the meshes' filenames in mesh_filenames. Args: mesh_filenames: a list containing the meshes to be cleaned. The mesh_filenames are relative filepath within `dataset_root_dir`. cleaned_root_dir: only for cleaning obj Retu

(
        mesh_filenames: T.List[str],
        dataset_root_dir: str,
        cleaned_root_dir: str,
)

Source from the content-addressed store, hash-verified

104
105
106def get_clean_mesh_filenames(
107 mesh_filenames: T.List[str],
108 dataset_root_dir: str,
109 cleaned_root_dir: str,
110) -> T.List[str]:
111 """
112 Get the clean the meshes' filenames in mesh_filenames.
113
114 Args:
115 mesh_filenames:
116 a list containing the meshes to be cleaned.
117 The mesh_filenames are relative filepath within `dataset_root_dir`.
118 cleaned_root_dir:
119 only for cleaning obj
120
121 Returns:
122 cleaned_mesh_filenames:
123 a list containing the cleaned meshes
124 """
125
126 if isinstance(mesh_filenames, str): # str, list, or tuple
127 mesh_filenames = [mesh_filenames]
128
129 cleaned_mesh_filenames = []
130 for mesh_filename in mesh_filenames:
131 name, ext = os.path.splitext(mesh_filename)
132 if ext.lower() == '.obj':
133 rel_mesh_filename = os.path.relpath(mesh_filename, dataset_root_dir)
134 cleaned_filename = os.path.join(
135 cleaned_root_dir,
136 rel_mesh_filename,
137 )
138 elif ext.lower() in {'.glb', '.gltf'}:
139 name, ext = os.path.splitext(mesh_filename)
140 cleaned_filename = f'{name}.gltf'
141 else:
142 cleaned_filename = mesh_filename
143
144 if os.path.exists(cleaned_filename):
145 cleaned_mesh_filenames.append(cleaned_filename)
146
147 return cleaned_mesh_filenames
148
149
150def gather_and_clean_dataset(

Callers 1

gather_and_clean_datasetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected