-
Notifications
You must be signed in to change notification settings - Fork 0
/
cremiGP_merge14.py
61 lines (42 loc) · 1.34 KB
/
cremiGP_merge14.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
import gp
import cPickle as pickle
import numpy as np
import os
HOMEDIR = '/n/home05/haehn/'
REGALDIR = '/n/regal/pfister_lab/haehn/'
DATADIR = HOMEDIR + 'data/CREMIGP/TEST/'
OUTDIR = REGALDIR + 'CREMIBIG/'
#
# load cnn
#
with open('nets/IPMLB_FULL_CREMI_FINAL.p', 'rb') as f:
cnn = pickle.load(f)
cnn.uuid = 'IPMLB'
#
# load data
#
input_image = []
input_prob = []
input_gold = []
input_rhoana = []
test_slices = range(60,65)# + range(25+20,50) + range(50+20,75)
for z in test_slices:
image, prob, gold, rhoana = gp.Util.read_cremi_section(os.path.expanduser('~/data/CREMIGP/TEST/'), z)
input_image.append(image)
input_prob.append(255.-prob)
input_gold.append(gold)
input_rhoana.append(rhoana)
original_mean_VI, original_median_VI, original_VI_s = gp.Legacy.VI(input_gold, input_rhoana)
# find merge errors, if we did not generate them before
merge_error_file = OUTDIR+'/merge_errors_65.p'
if os.path.exists(merge_error_file):
print 'Loading merge errors from file..'
with open(merge_error_file, 'rb') as f:
merge_errors = pickle.load(f)
else:
print 'Finding Top 5 merge errors..'
merge_errors = gp.Legacy.get_top5_merge_errors(cnn, input_image, input_prob, input_rhoana)
with open(merge_error_file, 'wb') as f:
pickle.dump(merge_errors, f)
print len(merge_errors), ' merge errors found.'
print 'All done.'