Delete raw_data/copy_data.py
Browse files- raw_data/copy_data.py +0 -48
raw_data/copy_data.py
DELETED
|
@@ -1,48 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
import os
|
| 3 |
-
import shutil
|
| 4 |
-
from tqdm import tqdm
|
| 5 |
-
def load_jsonl_file(file_path):
|
| 6 |
-
data = []
|
| 7 |
-
with open(file_path, 'r', encoding='utf-8') as f:
|
| 8 |
-
for line in f:
|
| 9 |
-
try:
|
| 10 |
-
data.append(json.loads(line))
|
| 11 |
-
except json.JSONDecodeError:
|
| 12 |
-
continue
|
| 13 |
-
return data
|
| 14 |
-
|
| 15 |
-
for i in range(1, 59, 1):
|
| 16 |
-
file_path = f'/home/yanqiao/data_yq/general_data/K-Radar/raw_data/annotation/sequence_{i}.jsonl'
|
| 17 |
-
datas = load_jsonl_file(file_path)
|
| 18 |
-
print(f"Processing sequence {i} with {len(datas)} data items.")
|
| 19 |
-
|
| 20 |
-
for data in tqdm(datas, desc=f"Copying files for sequence {i}", total=len(datas)):
|
| 21 |
-
data_item = data['data'][0]['item_0']
|
| 22 |
-
rgb_img = data_item['path']['images']
|
| 23 |
-
lidar_bev = data_item['path']['ldr_bev']
|
| 24 |
-
radar_bev = data_item['path']['rdr_bev']
|
| 25 |
-
|
| 26 |
-
dst_rgb_dir = f'/home/yanqiao/general_ai/ObsDriveBench/Dataset/raw_data/{i}/images/' + os.path.basename(rgb_img)
|
| 27 |
-
dst_lidar_dir = f'/home/yanqiao/general_ai/ObsDriveBench/Dataset/raw_data/{i}/lidar_bev_image/' + os.path.basename(lidar_bev)
|
| 28 |
-
dst_radar_dir = f'/home/yanqiao/general_ai/ObsDriveBench/Dataset/raw_data/{i}/radar_bev_image/' + os.path.basename(radar_bev)
|
| 29 |
-
|
| 30 |
-
rgb_img_wrt = rgb_img.replace('/images/', '/images_rendered/').replace(".png", "_no_obj.png")
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
os.makedirs(os.path.dirname(dst_rgb_dir), exist_ok=True)
|
| 35 |
-
os.makedirs(os.path.dirname(dst_lidar_dir), exist_ok=True)
|
| 36 |
-
os.makedirs(os.path.dirname(dst_radar_dir), exist_ok=True)
|
| 37 |
-
|
| 38 |
-
try:
|
| 39 |
-
shutil.copy(rgb_img_wrt, dst_rgb_dir)
|
| 40 |
-
shutil.copy(lidar_bev, dst_lidar_dir)
|
| 41 |
-
shutil.copy(radar_bev, dst_radar_dir)
|
| 42 |
-
except Exception as e:
|
| 43 |
-
print(f"Error copying files for sequence {i}: {e}")
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|