forked from lllyasviel/ControlNet-v1-1-nightly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest3.py
More file actions
71 lines (56 loc) · 2.14 KB
/
test3.py
File metadata and controls
71 lines (56 loc) · 2.14 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import json
# merged_data = {}
#
# for i in range(5,14):
# file_pre = 'BLIP2_split_by_count_and_grayscale' + str(i) + '.json'
# with open(file_pre, 'r') as f:
# data = json.load(f)
# merged_data[str(i)] = data[str(i)]
# data = data[str(i)]
#
# print('For count ', str(i) , ' grayscale ', len(data['grayscale']) , ' color count', len(data['color']))
#
# out_file = 'BLIP2_split_by_count_and_grayscale.json'
# with open(out_file, 'w') as f:
# json.dump(merged_data, f)
#----------------------------------------------------------------------------------------------------------------------
# data2 = 'BLIP2_split_by_count_recheck_tag_V4.json'
# with open(data2, 'r') as f:
# valid = json.load(f)
# total= 0
# for i in range(14):
# total += len(valid[str(i)])
# print("total is ", total)
# # print("for count ", -1 ," we have ", len( valid[str(-1)]) , ' samples ' ,len( valid[str(-1)])/total * 100, ' percentage.' )
# for i in range(14):
# print("for count ", i ," we have ", len( valid[str(i)]) , ' samples ' ,len( valid[str(i)])/total * 100, ' percentage.' )
#
#
# valid_v2 = 'BLIP2_split_by_count.json'
# with open(valid_v2, 'r') as f:
# valid_v2 = json.load(f)
#
# for i in range(13):
# valid_v2[str(i)].extend(valid[str(i)])
# print("After fix , for count ", i, " we have ", len(valid_v2[str(i)]),
# ' samples ', len(valid_v2[str(i)]) / total * 100,' percentage.')
#
# valid_v2['13'] = valid['13']
#
# out_path = 'BLIP2_split_by_count_V4.json'
# with open (out_path, 'w') as f:
# json.dump(valid_v2,f)
# update samples
#---------------------------------------------------------------------------------------------------------------------
data2 = 'BLIP2_split_by_count_and_grayscale.json'
with open(data2, 'r') as f:
data2 = json.load(f)
out = []
for i in range(5,14):
print(data2.keys())
out.extend(data2[str(i)]['color'])
print('For count ', str(i) , ' grayscale ', len(data2[str(i)]['grayscale']) , ' color count', len(data2[str(i)]['color']))
out_path = 'BLIP2_count_5_13_only_colored.json'
print("total colored sample:", len(out))
with open (out_path, 'w') as f:
json.dump(out, f)