Download utils/convert_transform.py from astra-vision/newtphys_dl3dv: direct link, hf CLI and curl.
- Browser
- Download file 972 Bytes
-
https://huggingface.co/datasets/astra-vision/newtphys_dl3dv/resolve/main/utils/convert_transform.py
- Command line
-
hf download hf://datasets/astra-vision/newtphys_dl3dv/utils/convert_transform.py
-
curl -L -o convert_transform.py https://huggingface.co/datasets/astra-vision/newtphys_dl3dv/resolve/main/utils/convert_transform.py
972 Bytes
| import yaml | |
| import json | |
| def read_yaml(file_path): | |
| with open(file_path, 'r') as file: | |
| data = yaml.safe_load(file) | |
| return data | |
| def read_json(file_path): | |
| with open(file_path, 'r') as file: | |
| data = json.load(file) | |
| return data | |
| def write_json(file_path, data): | |
| with open(file_path, 'w') as file: | |
| json.dump(data, file, indent=4) | |
| if __name__ == "__main__": | |
| # Example usage | |
| yaml_data = read_yaml('transforms.yaml') | |
| # print("YAML Data:", yaml_data['scene129']) | |
| json_data = read_json('used_scenes.json') | |
| print("JSON Data:", json_data) | |
| for data in json_data: | |
| print(data['name']) | |
| if data['name'].replace('_', '') in yaml_data: | |
| print(yaml_data[data['name'].replace('_', '')]) | |
| data['transforms'] = yaml_data[data['name'].replace('_', '')]['transform'] | |
| print("All data processed.") | |
| write_json('output.json', json_data) | |
| print("Data written to output.json") | |