AaronCIH / APGCC

ECCV24 - Improving Point-based Crowd Counting and Localization Based on Auxiliary Point Guidance
https://apgcc.github.io/
MIT License
26 stars 6 forks source link

it will be appricated if the training code is completed! #7

Open Glorainow opened 1 month ago

Glorainow commented 1 month ago

The evaluate_crowd_no_overlap function is not implemented. When would this be completed? image Look forward to try APGCC!

ty-zf commented 3 weeks ago

Hello, recently I am also doing research work related to crowd counting, this is the evaluate_crowd_no_overlap function part that I provided for reference

`@torch.no_grad() def evaluate_crowd_no_overlap(model, val_dl, device): model.to(device) model.eval()

Inference is performed on all images to compute the MAE

maes = []
mses = []
counts_pred, counts_true = [], []  # Storage of projected and real numbers
img_id = []  # 创建储存图片id的列表
# Iterate through the validation dataset
for samples, targets in val_dl:
    samples = samples.to(device)
    outputs = model(samples)

    # Assuming that the model output contains the predicted points and corresponding scores
    outputs_points = outputs['pred_points'][0]
    outputs_scores = torch.nn.functional.softmax(outputs['pred_logits'], -1)[:, :, 1][0]

    # Getting a count of real targets
    gt_cnt = targets[0]['point'].shape[0]

    # Filtering prediction points based on score thresholds
    threshold = 0.5
    points = outputs_points[outputs_scores > threshold].detach().cpu().numpy().tolist()
    predict_cnt = int((outputs_scores>threshold).sum())
    # accumulate MAE, MSE
    mae = abs(predict_cnt - gt_cnt)
    mse = (predict_cnt - gt_cnt) * (predict_cnt - gt_cnt)
    maes.append(float(mae))
    mses.append(float(mse))
    # Storage of projected and real numbers
    counts_pred.append(predict_cnt)
    counts_true.append(gt_cnt)
    img_id.append(int(targets[0]['image_id']))
# calc MAE, MSE
mae = np.mean(maes)
mse = np.sqrt(np.mean(mses))
# save_counts_to_file_sorted(f"{mse_dir}/counting_person_{mae:.2f}.txt", img_id, counts_pred)
return mae, mse`
nice98k commented 2 weeks ago

Hello, recently I am also doing research work related to crowd counting, this is the evaluate_crowd_no_overlap function part that I provided for reference

`@torch.no_grad() def evaluate_crowd_no_overlap(model, val_dl, device): model.to(device) model.eval() # Inference is performed on all images to compute the MAE maes = [] mses = [] counts_pred, counts_true = [], [] # Storage of projected and real numbers img_id = [] # 创建储存图片id的列表 # Iterate through the validation dataset for samples, targets in val_dl: samples = samples.to(device) outputs = model(samples)

    # Assuming that the model output contains the predicted points and corresponding scores
    outputs_points = outputs['pred_points'][0]
    outputs_scores = torch.nn.functional.softmax(outputs['pred_logits'], -1)[:, :, 1][0]

    # Getting a count of real targets
    gt_cnt = targets[0]['point'].shape[0]

    # Filtering prediction points based on score thresholds
    threshold = 0.5
    points = outputs_points[outputs_scores > threshold].detach().cpu().numpy().tolist()
    predict_cnt = int((outputs_scores>threshold).sum())
    # accumulate MAE, MSE
    mae = abs(predict_cnt - gt_cnt)
    mse = (predict_cnt - gt_cnt) * (predict_cnt - gt_cnt)
    maes.append(float(mae))
    mses.append(float(mse))
    # Storage of projected and real numbers
    counts_pred.append(predict_cnt)
    counts_true.append(gt_cnt)
    img_id.append(int(targets[0]['image_id']))
# calc MAE, MSE
mae = np.mean(maes)
mse = np.sqrt(np.mean(mses))
# save_counts_to_file_sorted(f"{mse_dir}/counting_person_{mae:.2f}.txt", img_id, counts_pred)
return mae, mse`

请问,你这部分代码能跑吗?结果如何?

little-seasalt commented 1 week ago

请问大家,有人能跑通训练代码吗?可以交流一下吗?