(tracks, scores, args)
| 283 | output = subprocess.call(command, shell=True, stdout=None) |
| 284 | |
| 285 | def evaluate_col_ASD(tracks, scores, args): |
| 286 | txtPath = args.videoFolder + '/col_labels/fusion/*.txt' # Load labels |
| 287 | predictionSet = {} |
| 288 | for name in {'long', 'bell', 'boll', 'lieb', 'sick', 'abbas'}: |
| 289 | predictionSet[name] = [[],[]] |
| 290 | dictGT = {} |
| 291 | txtFiles = glob.glob("%s"%txtPath) |
| 292 | for file in txtFiles: |
| 293 | lines = open(file).read().splitlines() |
| 294 | idName = file.split('/')[-1][:-4] |
| 295 | for line in lines: |
| 296 | data = line.split('\t') |
| 297 | frame = int(int(data[0]) / 29.97 * 25) |
| 298 | x1 = int(data[1]) |
| 299 | y1 = int(data[2]) |
| 300 | x2 = int(data[1]) + int(data[3]) |
| 301 | y2 = int(data[2]) + int(data[3]) |
| 302 | gt = int(data[4]) |
| 303 | if frame in dictGT: |
| 304 | dictGT[frame].append([x1,y1,x2,y2,gt,idName]) |
| 305 | else: |
| 306 | dictGT[frame] = [[x1,y1,x2,y2,gt,idName]] |
| 307 | flist = glob.glob(os.path.join(args.pyframesPath, '*.jpg')) # Load files |
| 308 | flist.sort() |
| 309 | faces = [[] for i in range(len(flist))] |
| 310 | for tidx, track in enumerate(tracks): |
| 311 | score = scores[tidx] |
| 312 | for fidx, frame in enumerate(track['track']['frame'].tolist()): |
| 313 | s = numpy.mean(score[max(fidx - 2, 0): min(fidx + 3, len(score) - 1)]) # average smoothing |
| 314 | faces[frame].append({'track':tidx, 'score':float(s),'s':track['proc_track']['s'][fidx], 'x':track['proc_track']['x'][fidx], 'y':track['proc_track']['y'][fidx]}) |
| 315 | for fidx, fname in tqdm.tqdm(enumerate(flist), total = len(flist)): |
| 316 | if fidx in dictGT: # This frame has label |
| 317 | for gtThisFrame in dictGT[fidx]: # What this label is ? |
| 318 | faceGT = gtThisFrame[0:4] |
| 319 | labelGT = gtThisFrame[4] |
| 320 | idGT = gtThisFrame[5] |
| 321 | ious = [] |
| 322 | for face in faces[fidx]: # Find the right face in my result |
| 323 | faceLocation = [int(face['x']-face['s']), int(face['y']-face['s']), int(face['x']+face['s']), int(face['y']+face['s'])] |
| 324 | faceLocation_new = [int(face['x']-face['s']) // 2, int(face['y']-face['s']) // 2, int(face['x']+face['s']) // 2, int(face['y']+face['s']) // 2] |
| 325 | iou = bb_intersection_over_union(faceLocation_new, faceGT, evalCol = True) |
| 326 | if iou > 0.5: |
| 327 | ious.append([iou, round(face['score'],2)]) |
| 328 | if len(ious) > 0: # Find my result |
| 329 | ious.sort() |
| 330 | labelPredict = ious[-1][1] |
| 331 | else: |
| 332 | labelPredict = 0 |
| 333 | x1 = faceGT[0] |
| 334 | y1 = faceGT[1] |
| 335 | width = faceGT[2] - faceGT[0] |
| 336 | predictionSet[idGT][0].append(labelPredict) |
| 337 | predictionSet[idGT][1].append(labelGT) |
| 338 | names = ['long', 'bell', 'boll', 'lieb', 'sick', 'abbas'] # Evaluate |
| 339 | names.sort() |
| 340 | F1s = 0 |
| 341 | for i in names: |
| 342 | scores = numpy.array(predictionSet[i][0]) |
no test coverage detected