Primary competition visual

CGIAR Crop Damage Classification Challenge

Helping Africa
$10 000 USD
Completed (over 2 years ago)
Classification
1156 joined
346 active
Starti
27 Oct 23
Closei
28 Jan 24
Reveali
28 Jan 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
User avatar

Hello ridwan. Were you able to solve the issue?

Upvotes 0
User avatar

Please share how it was solved.

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()]))

Upvotes 1