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

Doubt in predict.py #1

Open
ronroc opened this issue Jul 26, 2017 · 1 comment
Open

Doubt in predict.py #1

ronroc opened this issue Jul 26, 2017 · 1 comment

Comments

@ronroc
Copy link

ronroc commented Jul 26, 2017

Hi Scotty - Tks for the amazing code, helped me a lot , had a doubt in predict.py . Is it possible to explain what was done in predict.py at a high level, any references to any literature on these methods would be great
Thanks -

@scottykwok
Copy link
Owner

Hi Ronroc, for predict.py, the main logic is in predict_and_crop():

# this get the unet prediction
predict = model.predict(img, batch_size=1, verbose=0) 

# this perform auto binary threshold to give a binary mask
binary_mask = to_binary_mask(predict[0])

# this use morphology open & close to remove small holes in the mask
morphed_mask = morphology_clean(binary_mask)

# this find the coordinates & weight & height of the bounding box that bound the morphed_mask
x, y, w, h = find_bbox(morphed_mask, margin_factor)

Then the program crop the original image based on x,y,w,h.

It may be helpful to visualize the mask and the bounding box overlap on the original image, you can do so by setting:

generate_previews = True
generate_masks = True

and the visualization will be generated in 'xxxx_preview.jpg'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants