forked from lllyasviel/ControlNet-v1-1-nightly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter_failed_image.py
65 lines (47 loc) · 1.28 KB
/
filter_failed_image.py
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
import cv2
import numpy as np
import json
file_path = 'shapenet_v1.json'
views_folder = "/yuch_ws/views_release"
with open(file_path, 'r') as f:
folders = json.load(f)
c = 0
total = len(folders)
print(total)
bad_path = []
good_path = []
good_dist = {}
bad_dist = {}
for folder in folders:
img_path = views_folder + '/' + folder + '/000.png'
img =cv2.imread(img_path)
prompt_p = views_folder + '/' + folder + '/BLIP_best_text_v2.txt'
with open(prompt_p,'r') as f:
prompt = f.readline()
if img.sum() == 328200:
bad_path.append(folder)
if prompt not in bad_dist:
bad_dist[prompt] = 1
else:
bad_dist[prompt] += 1
print(c , folder)
c+=1
else:
good_path.append(folder)
if prompt not in good_dist:
good_dist[prompt] = 1
else:
good_dist[prompt] += 1
out_path = 'shapenet_v1_good.json'
with open (out_path,'w') as f:
json.dump(good_path,f)
out_path = 'shapenet_v1_good_dist.json'
with open (out_path,'w') as f:
json.dump(good_dist,f)
out_path = 'shapenet_v1_bad.json'
with open (out_path,'w') as f:
json.dump(bad_path,f)
out_path = 'shapenet_v1_bad_dist.json'
with open (out_path,'w') as f:
json.dump(bad_dist,f)
print(c, total, c/total)