Created
September 28, 2018 08:52
-
-
Save pietz/59be226fe2d6db8abd1acd8b07e8fcae to your computer and use it in GitHub Desktop.
Take a YOLO style detection mask, convert it to a pixel mask and visualize it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def draw_det(det, size=256): | |
g = float(len(det)) | |
msk = np.zeros((size,size)) | |
for col in range(det.shape[0]): | |
for row in range(det.shape[1]): | |
p,x,y,w,h = det[col,row] | |
if p > 0.5: | |
l = int(size*(col/g+x/g-w/2)) | |
r = int(size*(col/g+x/g+w/2)) | |
t = int(size*(row/g+y/g-h/2)) | |
b = int(size*(row/g+y/g+h/2)) | |
msk[l:r,t:b] = 1 | |
plt.imshow(msk) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment