Open ashlinghosh opened 4 years ago
I try the same... If you haven't infinity video memory the only solution is to crop images with overlapping sections (to don't miss a face). This ends in doubled detected face:
def cropwithoverlay(img, max_w, max_h, overlap_per = 25.0):
stepsize_w = int(float(max_w) * (100.0 - overlap_per) / 100.0)
stepsize_h = int(float(max_h) * (100.0 - overlap_per) / 100.0)
rows, columns, _ = img.shape
img_crop_list = []
if rows <= max_h and columns <= max_w:
return [[0,max_h,0,max_w]]
for row in range(0, rows, stepsize_w):
row2 = min(row + max_h, rows)
for col in range(0, columns, stepsize_h):
col2 = min(col + max_w, columns)
img_crop_list.append([row,row2,col,col2])
return img_crop_list
To calculate the boxes in the large image... My current try is to detect min 50 % overlapping boxes of the largest box and mark this compare as doubled detected box...
def faceboxisdoubled(a, b, threshold = 0.49): # returns False if rectangles don't intersect
dx = min(a[2], b[2]) - max(a[0], b[0])
dy = min(a[3], b[3]) - max(a[1], b[1])
#intersect?
if (dx>=0) and (dy>=0):
max_box_sqr = max((a[2] - a[0]) * (a[3] - a[1]), (b[2] - b[0]) * (b[3] - b[1]))
if (dx*dy) > (max_box_sqr * threshold):
return True
return False
49 % is sometimes possible and valid in large crowds... you could play with this value...
I stuck at a function to delete the double (or tripple) detected boxes from the list and keep the larger one. I should try to sleep more :D. If someone has the solution please write it down. Thx
best regards
Basti
@Counterfeiter Have you continued to implement the solution?
I'm trying to retrain retinaface with a custom dataset. My images are of resolution 1920x1080. The average width and height of faces in the images are ~20 pixels. I have around 10k images for training. So far, the model is not able to identify faces. Is there any preprocessing i can do like resizing and cropping which can help in improving the detection accuracy?