Primary competition visual

Digital Africa Plantation Counting Challenge

Helping Côte d'Ivoire
$10 000 USD
Challenge completed over 2 years ago
Prediction
Computer Vision
Object Detection
701 joined
219 active
Starti
Feb 23, 23
Closei
Apr 09, 23
Reveali
Apr 09, 23
User avatar
TAUIL_Abdelilah
university abdelmalek essaadi
Clean baseline code - LB: 2.542369639
Notebooks · 28 Feb 2023, 04:25 · 9

In this video I train a model to solve this competition from scratch, from end to end, using PyTorch

https://www.youtube.com/watch?v=SKHgz_bRpCs

Enjoy^_^

Discussion 9 answers
User avatar
Siwar_NASRI

Thanks @TAUIL_Abdelilah for sharing your hard work

1 Mar 2023, 10:36
Upvotes 1

Thanks @TAUIL_Abdelilah How elegant it is!

1 Mar 2023, 16:19
Upvotes 1

Great job ! But i think you did a small mistake when checking the validation score : you are averaging rmse of different batches. You'd rather store the predictions and then calculate the rmse.

2 Mar 2023, 12:18
Upvotes 3
User avatar
TAUIL_Abdelilah
university abdelmalek essaadi

Interesting, I thought averaging rmse of all batches will give the same results as store the predictions and then calculate the rmse. But I was wrong. I just updated the check_accuracy and hopefully fix the mistake.

This is the updated check accuracy, can you review it and see if I'm checking the accuracy the right way:

def check_acc_update(loader, model):    
    all_preds = np.array([]); all_groud_truth = np.array([])
    model.eval()
    with torch.no_grad():
        for x,y in tqdm(loader):
            x = x.to('cuda').to(torch.float32)
            y = y.to(torch.float).unsqueeze(1)
            
            all_preds       = np.append(all_preds, (model(x).cpu()))
            all_groud_truth = np.append(all_groud_truth, (y.cpu()))
    loss = np.sqrt(mean_squared_error(all_preds, all_groud_truth))
    print(f'Loss function: {loss}')
    model.train()
    return loss

Thanks for the feadback @Reacher.

User avatar
Siwar_NASRI

hi @TAUIL_Abdelilah ,

your function was false before because you tend to return the loss of only the last batch, and it is the same to return the average of each batch loss or the loss of all predictions with a reduction="mean".

and this function does't return the accuracy (the fraction of correctly predicted divided by the total of predictions), here you are looking for the validation loss (!=train loss: you can't use numpy to calculate loss for a grading train function).

where did you get the semi_data.csv ? which contains the bounding box data. in zindi's data section i'm not seeing any file like this.

26 Mar 2023, 12:38
Upvotes 0
User avatar
TAUIL_Abdelilah
university abdelmalek essaadi

I didn't get semi_data.csv, I don't use any bounding box in the notebook.

I use only the data that zindi provide.

Thanks@TAUIL_Abdedlilah. 
I have one doubt, during training why did you did model.zero_grad() not opt.zero_grad()?
2 Apr 2023, 18:23
Upvotes 0