Skip to content

Commit d7a1de9

Browse files
ok
1 parent fb52c5d commit d7a1de9

File tree

6 files changed

+4656
-4627
lines changed

6 files changed

+4656
-4627
lines changed

data.py

+36-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import skimage.measure
2020

2121
data_path = 'raw/'
22-
save_path = '/mnt/data1/yihuihe/mnc/'
22+
save_path = '/mnt/data1/yihuihe/mnc_small/'
2323
image_rows = 420
2424
image_cols = 580
2525

@@ -72,26 +72,41 @@ def preprocess(imgs, img_rows,img_cols):
7272
return imgs_p
7373

7474
def detseg():
75-
out_rows=384
76-
out_cols=512
75+
# out_rows=240
76+
# out_cols=320
77+
out_rows=160
78+
out_cols=224
7779
imgs_train = np.load('imgs_train.npy')
78-
imgs_train -=imgs_train.mean(0)[np.newaxis,]
79-
imgs_train /=imgs_train.std()
80-
imgs_train=preprocess(imgs_train, out_rows,out_cols)
80+
imgs_train=preprocess(imgs_train, out_rows,out_cols).astype(np.float32)
81+
mean_image=imgs_train.mean(0)[np.newaxis,]
82+
imgs_train -=mean_image
83+
print(np.histogram(imgs_train))
84+
std_image=imgs_train.std(0)[np.newaxis,]
85+
imgs_train /=std_image
86+
print(np.histogram(imgs_train))
87+
8188
imgs_mask_train = np.load('imgs_mask_train.npy')
82-
imgs_mask_train[imgs_mask_train<=50]=0
83-
imgs_mask_train[imgs_mask_train>50]=1
8489
imgs_mask_train=preprocess(imgs_mask_train, out_rows,out_cols)
85-
90+
imgs_mask_train[imgs_mask_train<=50]=False
91+
imgs_mask_train[imgs_mask_train>50]=True
92+
print(np.histogram(imgs_mask_train))
93+
8694
# if os.path.exists(save_path+'data.npy')==False:
87-
np.save(save_path+'data.npy',imgs_train.astype(np.uint8))
95+
np.save(save_path+'mean.npy',mean_image)
96+
np.save(save_path+'std.npy',std_image)
97+
np.save(save_path+'data.npy',imgs_train.astype(np.float32))
8898
print('save data')
89-
np.save(save_path+'mask.npy',imgs_mask_train.astype(np.uint8))
99+
np.save(save_path+'mask.npy',imgs_mask_train.astype(np.bool))
90100
print('save mask')
91101
del imgs_train
92102

93103
bboxes=[]
94104
masks=[]
105+
106+
acc_width=[]
107+
acc_height=[]
108+
max_width=0
109+
95110
for percent,label in enumerate(imgs_mask_train):
96111
if percent % 100==0:
97112
print(percent)
@@ -112,12 +127,22 @@ def detseg():
112127
ymax=idx_map[0].max()
113128
xmin=idx_map[1].min()
114129
xmax=idx_map[1].max()
130+
131+
max_width=foregroundIdx.shape[1]
132+
acc_width.append(xmax-xmin)
133+
acc_height.append(ymax-ymin)
115134
# print(xmin,ymin,xmax,ymax)
116135
instance_masks.append(label[ymin:ymax,xmin:xmax])
117136
gt_boxes.append([xmin,ymin,xmax,ymax,1])
118137
bboxes.append(gt_boxes)
119138
masks.append(instance_masks)
120139

140+
print("xmax", max_width, max(acc_width))
141+
H, xedges, yedges=np.histogram2d(acc_width,acc_height, bins=50)
142+
plt.imshow(H, interpolation='nearest', origin='low',
143+
extent=[xedges[0], xedges[-1], yedges[0], yedges[-1]])
144+
plt.show()
145+
121146
np.save(save_path+'roidb.npy',np.array(bboxes))
122147
np.save(save_path+'maskdb.npy',np.array(masks))
123148

resnet_50.png

2.16 MB
Loading

0 commit comments

Comments
 (0)