Skip to content

Commit

Permalink
create_submissions fixed for 0 nuclei
Browse files Browse the repository at this point in the history
  • Loading branch information
vdurnov committed Apr 12, 2018
1 parent 73ee984 commit 15b156e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions victor/create_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def pred_to_rles(y_pred):
total_cnt = 0
im_idx = 0

empty_cnt = 0

for f in tqdm(sorted(listdir(test_pred_folder))):
if path.isfile(path.join(test_pred_folder, f)) and '.png' in f:
img_id = f.split('.')[0]
Expand Down Expand Up @@ -177,8 +179,13 @@ def pred_to_rles(y_pred):
cv2.imwrite(path.join(pred_folder, test_out_folders[sub_id], f.replace('.png', '.tif')), pred_labels)

rle = list(pred_to_rles(pred_labels))
rles.extend(rle)
new_test_ids.extend([img_id] * len(rle))
if len(rle) == 0:
empty_cnt += 1
rles.extend([''])
new_test_ids.extend([img_id])
else:
rles.extend(rle)
new_test_ids.extend([img_id] * len(rle))

clr_labels = label2rgb(pred_labels, bg_label=0)
clr_labels *= 255
Expand All @@ -192,7 +199,7 @@ def pred_to_rles(y_pred):
sub['EncodedPixels'] = pd.Series(rles).apply(lambda x: ' '.join(str(y) for y in x))
sub.to_csv(path.join(pred_folder, 'submission_{0}.csv'.format(sub_id)), index=False)

print('total_cnt', total_cnt, 'removed', removed, 'replaced', replaced)
print('total_cnt', total_cnt, 'removed', removed, 'replaced', replaced, 'empty:', empty_cnt)
print(bst_k)

elapsed = timeit.default_timer() - t0
Expand Down

0 comments on commit 15b156e

Please sign in to comment.