Skip to content

Instantly share code, notes, and snippets.

View enric1994's full-sized avatar

Enric Moreu enric1994

View GitHub Profile
@enric1994
enric1994 / one_line_print.py
Created November 9, 2018 14:51
Print stuff in Python 2.7 always in the same line using carriage return
import sys,time
for i in xrange(100):
time.sleep(1)
sys.stdout.write('\r One line print! ' + str(i))
sys.stdout.flush()
@enric1994
enric1994 / iou.py
Last active November 9, 2018 17:10
Intersection of Union (IoU). Evaluates the accuracy using the ground truth and the prediction
def eval_iou(img1,img2):
m_img1 = img1 > 0
img1[m_img1] = 1
m_img2 = img2 > 0
img2[m_img2] = 1
overlap = img1*img2
union = img1 + img2