Primary competition visual

CGIAR Crop Damage Classification Challenge

Helping Africa
$10 000 USD
Completed (~2 years ago)
Classification
1148 joined
347 active
Starti
Oct 27, 23
Closei
Jan 28, 24
Reveali
Jan 28, 24
User avatar
adejumoridwan
Ahmadu bello university
File Not Found Error
Help Ā· 3 Jan 2024, 13:03 Ā· 3

Please this is my kaggle notebook https://www.kaggle.com/code/ridwanadejumo/agric-competition, I am facing the following error when trying to run the starter code

This is where the problem is

def cross_entropy(predictions, targets):

predictions = predictions.sigmoid()

return torch.where(targets==1, 1-predictions, predictions).mean()

def train_model(data):

df = data.copy()

for fold in range(N_FOLDS):

df['is_valid'] = (df['fold'] == fold)

print(f'Training fold: {fold}')

dls = ImageDataLoaders.from_df(

df, #pass in train DataFrame

valid_col='is_valid',

seed=SEED, #seed

fn_col='path', #filename/path is in the second column of the DataFrame

label_col='target', #label is in the first column of the DataFrame

label_delim=' ',

y_block=MultiCategoryBlock, #The type of target

bs=BATCH_SIZE, #pass in batch size

num_workers=NUM_WORKER,

item_tfms=Resize(IMGSZ), #pass in item_tfms

batch_tfms=setup_aug_tfms([Brightness(), Contrast(), Flip(), Rotate()]))

model = create_model(f'{MODEL_BASE}', pretrained=True, num_classes=dls.c)

learn = Learner(dls, model, loss_func=BCEWithLogitsLossFlat(), metrics=AccumMetric(cross_entropy)).to_fp16()

learn.fit_one_cycle(EPOCHS, INIT_LR, cbs=[SaveModelCallback(), EarlyStoppingCallback(monitor='cross_entropy', comp=np.less, patience=PATIENCE), CSVLogger(append=True)])

learn = learn.to_fp32()

learn.save(f'{MODEL_BASE}_fold{fold}', with_opt=False)

FileNotFoundError: [Errno 2] No such file or directory: './/kaggle/input/zindi-cgiar-crop-damage-dataset/images/images/d036341be8d6cd59851cb80bcc9a70cc9fbdba30.jpg

Discussion 3 answers

Hello ridwan. Were you able to solve the issue?

5 Jan 2024, 20:53
Upvotes 0

Please share how it was solved.

5 Jan 2024, 21:37
Upvotes 0
User avatar
sakthivelj

path=f'{DATASET_DIR}', add this to resolve the issue

dls = ImageDataLoaders.from_df(

df,

path=f'{DATASET_DIR}',

valid_col='is_valid',

fn_col='path',

label_col='target',

label_delim=' ',

y_block=MultiCategoryBlock,

batch_tfms=setup_aug_tfms([Brightness(), Contrast(), Flip(), Rotate()]))

18 Jan 2024, 07:36
Upvotes 1