features['Final_x'] = features['Future_x'].apply(lambda x: x[-1]) features['Final_y'] = features['Future_y'].apply(lambda y: y[-1]) ##################### Compute velocity and make predictions ##################### print('Computing velocity...') features['Velocity_x'] = features['Past_x'].apply(lambda x: utils.mean_velocity(x, VELOCITY_FRAMES)) features['Velocity_y'] = features['Past_y'].apply(lambda y: utils.mean_velocity(y, VELOCITY_FRAMES)) features['Predicted_x'] = features['Mid_x'] + (MIN_LENGTH_FUTURE * features['Velocity_x']) features['Predicted_y'] = features['Mid_y'] + (MIN_LENGTH_FUTURE * features['Velocity_y']) print('Getting predictions...') features['Predicted_x_seq'] = features.apply( lambda x: utils.get_seq_preds(x['Mid_x'], x['Velocity_x'], MIN_LENGTH_FUTURE), axis=1) features['Predicted_y_seq'] = features.apply( lambda x: utils.get_seq_preds(x['Mid_y'], x['Velocity_y'], MIN_LENGTH_FUTURE), axis=1) features['E_x'] = features.apply(lambda x: (x['Future_x'] - x['Predicted_x_seq']), axis=1) features['E_y'] = features.apply(lambda y: (y['Future_y'] - y['Predicted_y_seq']), axis=1) ##################### Get errors ##################### print('Computing errors...') features['MSE_15'] = features.apply( lambda x: utils.calc_mse(x['Predicted_x_seq'], x['Future_x'], x['Predicted_y_seq'], x['Future_y'], 15), axis=1) features['MSE_10'] = features.apply( lambda x: utils.calc_mse(x['Predicted_x_seq'], x['Future_x'], x['Predicted_y_seq'], x['Future_y'], 10), axis=1) features['MSE_5'] = features.apply( lambda x: utils.calc_mse(x['Predicted_x_seq'], x['Future_x'], x['Predicted_y_seq'], x['Future_y'], 5), axis=1)
# VELOCITY_FRAMES ~ len(x)之间的平均速度,该条目为单一值 features['Velocity_x'] = features['Past_x'].apply( lambda x: utils.mean_velocity(x, VELOCITY_FRAMES)) features['Velocity_y'] = features['Past_y'].apply( lambda y: utils.mean_velocity(y, VELOCITY_FRAMES)) # 计算 MIN_LENGTH_FUTURE 之后匀速运动的位置,该条目为单一值 # 该值将会作为ResNet的初始值,模型初始权重(“赢在起跑线”) features['Predicted_x'] = features['Mid_x'] + (MIN_LENGTH_FUTURE * features['Velocity_x']) features['Predicted_y'] = features['Mid_y'] + (MIN_LENGTH_FUTURE * features['Velocity_y']) # 产生 MIN_LENGTH_FUTURE 长度的未来位置序列,该值为序列 features['Predicted_x_seq'] = features.apply(lambda x: utils.get_seq_preds( x['Mid_x'], x['Velocity_x'], MIN_LENGTH_FUTURE), axis=1) features['Predicted_y_seq'] = features.apply(lambda x: utils.get_seq_preds( x['Mid_y'], x['Velocity_y'], MIN_LENGTH_FUTURE), axis=1) # 当前帧之后的15帧的gt与CV之间的差值,该值为序列 features['E_x'] = features.apply(lambda x: (x['Future_x'] - x['Predicted_x_seq']), axis=1) features['E_y'] = features.apply(lambda y: (y['Future_y'] - y['Predicted_y_seq']), axis=1) ##################### Get errors ##################### features['MSE'] = features.apply(
features['Velocity_x'] = features['Past_x'].apply( lambda x: utils.mean_velocity(x, len(x) - VELOCITY_FRAMES)) features['Velocity_y'] = features['Past_y'].apply( lambda y: utils.mean_velocity(y, len(y) - VELOCITY_FRAMES)) # 计算匀速运动终点 # features['Predicted_x'] = features['Mid_x'] + \ # (MIN_LENGTH_FUTURE * features['Velocity_x']) # features['Predicted_y'] = features['Mid_y'] + \ # (MIN_LENGTH_FUTURE * features['Velocity_y']) print('Getting predictions...') # 计算匀速运动坐标序列 features['Predicted_x_seq'] = features.apply( lambda x: utils.get_seq_preds(x['Mid_x'], x['Velocity_x'], 60), axis=1) features['Predicted_y_seq'] = features.apply( lambda x: utils.get_seq_preds(x['Mid_y'], x['Velocity_y'], 60), axis=1) # 作为训练的ground truth,其代表匀速运动与真实值的误差序列 # features['E_x'] = features.apply(lambda x: ( # x['Future_x'] - x['Predicted_x_seq']), axis=1) # features['E_y'] = features.apply(lambda y: ( # y['Future_y'] - y['Predicted_y_seq']), axis=1) ##################### Get errors ##################### print('Computing errors...') # features['MSE_15'] = features.apply( # lambda x: utils.calc_mse(x['Predicted_x_seq'], x['Future_x'], x['Predicted_y_seq'], x['Future_y'], 15), axis=1) # features['MSE_10'] = features.apply( # lambda x: utils.calc_mse(x['Predicted_x_seq'], x['Future_x'], x['Predicted_y_seq'], x['Future_y'], 10), axis=1)