Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config for resnet50 #1

Merged
merged 9 commits into from
Mar 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update inference.py
For fix the problem of submission
  • Loading branch information
John1231983 committed Mar 3, 2018
commit 0e4512b3d26f65eeff58cd1977fbb2f1bbd74e0b
34 changes: 10 additions & 24 deletions inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from inference_config import inference_config
from bowl_dataset import BowlDataset
from utils import rle_encode, rle_decode, rle_to_string

import functions as f
ROOT_DIR = os.getcwd()
MODEL_DIR = os.path.join(ROOT_DIR, "logs")

Expand All @@ -32,7 +32,8 @@

output = []
sample_submission = pd.read_csv('stage1_sample_submission.csv')

ImageId = []
EncodedPixels = []
for image_id in tqdm(sample_submission.ImageId):
image_path = os.path.join('stage1_test', image_id, 'images', image_id + '.png')

Expand All @@ -41,25 +42,10 @@
r = results[0]

masks = r['masks']

count = masks.shape[-1]
occlusion = np.logical_not(masks[:, :, -1]).astype(np.uint8)

for i in range(count - 2, -1, -1):
mask = masks[:, :, i] * occlusion
mask_rle = rle_to_string(rle_encode(mask))

# Sanity check
try:
rle_decode(mask_rle, original_image.shape[:-1])
output.append([image_id, mask_rle])
occlusion = np.logical_and(occlusion, np.logical_not(masks[:, :, i]))

except Exception as e:
print(e)
print(image_id)
print('---')

output_df = pd.DataFrame(output, columns=['ImageId', 'EncodedPixels'])
output_df.to_csv('submission.csv', index=False, encoding='utf-8')

ImageId_batch, EncodedPixels_batch = f.numpy2encoding_no_overlap2(masks, image_id, r['scores'])
ImageId += ImageId_batch
EncodedPixels += EncodedPixels_batch



f.write2csv('submission_v2.csv', ImageId, EncodedPixels)