| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | ''' |
| | Download specific Objaverse meshes given their UUIDs. |
| | |
| | Installation: |
| | pip install trimesh==4.5.3 objaverse==0.1.7 meshcat==0.0.12 webdataset==0.2.111 |
| | |
| | Usage: |
| | python download_objaverse.py --uuid_list /path_to_dataset/splits/franka/valid_scenes.json --output_dir /tmp/objs |
| | ''' |
| | import argparse |
| | import json |
| | import os |
| | import shutil |
| | from objaverse import load_objects |
| | from pathlib import Path |
| | from dataset import load_uuid_list |
| |
|
| | def download_objaverse_meshes(uuids: list[str], output_dir: str): |
| | """ |
| | Download specific Objaverse meshes given their UUIDs. |
| | |
| | Args: |
| | uuid_list_path (str): Path to JSON file containing list of UUIDs |
| | output_dir (str): Directory where meshes will be saved |
| | """ |
| | |
| | os.makedirs(output_dir, exist_ok=True) |
| | |
| | print(f"Found {len(uuids)} UUIDs to download") |
| | |
| | |
| | objects = load_objects(uids=uuids) |
| |
|
| | map_uuid_to_path = {} |
| | |
| | |
| | for uuid in uuids: |
| | try: |
| | |
| | obj_path = objects[uuid] |
| | |
| | if obj_path is None: |
| | print(f"Failed to download object {uuid}") |
| | continue |
| | |
| | |
| | dest_path = os.path.join(output_dir, os.path.basename(obj_path)) |
| | |
| | shutil.copy2(obj_path, dest_path) |
| | |
| | print(f"Successfully downloaded and saved object {uuid}, saved to {dest_path}") |
| | map_uuid_to_path[uuid] = dest_path |
| |
|
| | os.remove(obj_path) |
| | json.dump(map_uuid_to_path, open(os.path.join(output_dir, "map_uuid_to_path.json"), "w")) |
| | |
| | except Exception as e: |
| | print(f"Error processing object {uuid}: {e}") |
| | |
| | print("Download complete!") |
| |
|
| | def parse_args(): |
| | parser = argparse.ArgumentParser() |
| | parser.add_argument("--uuid_list", type=str, help="Path to UUID list or Json. This can be the split json file from the GraspGen dataset") |
| | parser.add_argument("--output_dir", type=str, help="Path to output directory") |
| | return parser.parse_args() |
| |
|
| |
|
| | if __name__ == "__main__": |
| | args = parse_args() |
| | uuid_list = load_uuid_list(args.uuid_list) |
| | download_objaverse_meshes(uuid_list, args.output_dir) |