|
|
import os |
|
|
import json |
|
|
from concurrent.futures import ThreadPoolExecutor, as_completed |
|
|
from tqdm import tqdm |
|
|
import datasets |
|
|
|
|
|
|
|
|
root_path = './Datasets/' |
|
|
data = datasets.load_dataset("allenai/pixmo-points", split="train", cache_dir=root_path) |
|
|
len_data = len(data) |
|
|
image_folder = os.path.join(root_path,"pixmo_images") |
|
|
|
|
|
valid_one_points_indices = '/home/panwen.hu/workspace/jian.zhang/EAI/EAI2025/pixmo-points/Datasets/valid_one_points_indices.json' |
|
|
|
|
|
def load_json(file_path): |
|
|
with open(file_path, 'r', encoding='utf-8') as f: |
|
|
data = json.load(f) |
|
|
return data |
|
|
|
|
|
|
|
|
data_json = load_json(valid_one_points_indices) |
|
|
index_list = data_json.get("index", []) |
|
|
|
|
|
ins_all = set() |
|
|
|
|
|
def process_item(i): |
|
|
print(i,len_data,f"{(i / len_data) * 100:.3f}%") |
|
|
item = data[i] |
|
|
instruction = item['label'] |
|
|
return instruction |
|
|
|
|
|
|
|
|
with ThreadPoolExecutor(max_workers=64) as executor: |
|
|
|
|
|
futures = [ |
|
|
executor.submit(process_item, i) for i in index_list |
|
|
] |
|
|
|
|
|
|
|
|
for future in tqdm(as_completed(futures), total=len_data, desc="Processing"): |
|
|
instruction = future.result() |
|
|
ins_all.add(instruction) |
|
|
|
|
|
|
|
|
json_path = os.path.join('/home/panwen.hu/workspace/jian.zhang/EAI/EAI2025/Afford-RDT/data/encode_language/', "pixmo_all_instructions_one_point.json") |
|
|
with open(json_path, "w", encoding="utf-8") as f: |
|
|
json.dump(list(ins_all), f, indent=4) |