File size: 1,535 Bytes
a03ed61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import hashlib
import datasets
import json


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")


hash_image_all = set()
indices_one_point_all = []
hash_image_one_point_all = set()

record = {'index':[],'image_hash':set()}

for i,example in enumerate(data):
    print(i,len_data,f"{(i / len_data) * 100:.3f}%")
    points = example['points']
    image_hash = example["image_sha256"]
    if len(points) == 1:
        indices_one_point_all.append(i)
        hash_image_one_point_all.add(image_hash)

    
    
    hash_image_all.add(image_hash)
    image_url = example["image_url"]
    image_path = os.path.join(image_folder, f"{image_hash}.jpg")
    
    if not os.path.exists(image_path):
        print('image does not exist, skip')
        continue  # 图片不存在,跳过
    if os.path.exists(image_path) and len(points)==1:
        record['index'].append(i)
        record['image_hash'].add(image_hash)

record['number of indices'] = len(record['index'])
record['number of images'] = len(record['image_hash'])

print('all images',len(hash_image_all))
print('all one point',len(indices_one_point_all),len(hash_image_one_point_all))
print('downloaded one ponit','number of indices',len(record['index']),'images:',len(record['image_hash']))

record['image_hash'] = list(record['image_hash'])
with open("valid_one_points_indices.json", "w") as f:
    json.dump(record, f, indent=4)