Kaggle competition: Bengali.AI Handwritten Grapheme Classification
sub_1 = pd.read_csv('.. /input/submission-examples/sub66842.csv', keep_default_na=True)
 sub_1['ImageId'] = sub_1['Image_Label'].apply(lambda x: x.split('_')[0])
 sub_1['EncodedPixels'].replace({np.nan: ''}, inplace=True)
 sub_1.head(10 )<load_from_csv>
SEED = 42
LABELS = 'train.csv'
warnings.filterwarnings("ignore")
 fastai.__version__
sub_2 = pd.read_csv('.. /input/submission-examples/sub67042.csv', keep_default_na=True)
 sub_2['ImageId'] = sub_2['Image_Label'].apply(lambda x: x.split('_')[0])
 sub_2['EncodedPixels'].replace({np.nan: ''}, inplace=True)
 sub_2.head(10 )<load_from_csv>
learn = load_learner(Path('/kaggle/input/bgraph-rn50-model'),'try2A-rn50-im128-wcv.pkl')
<load_from_csv><EOS> 
%%time
row_id,target = [],[]
imgnet_mean = [0.485, 0.456, 0.406]
imgnet_std = [0.229, 0.224, 0.225]
for fname in TEST:
df = pd.read_parquet(fname)
 data = 255 - df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH ).astype(np.uint8)
 for idx in range(len(df)) :
name = df.iloc[idx,0]
img =(data[idx]*(255.0/data[idx].max())).astype(np.uint8)
 img = crop_resize(img)
 img = np.stack(( img,)*3,axis=-1)
 img = pil2tensor(img,np.float32 ).div_(255)
 pred, tsor, prob = learn.predict(Image(img))
row_id += [f'{name}_consonant_diacritic',f'{name}_grapheme_root',f'{name}_vowel_diacritic']
c = learn.data.classes
target += [
c[ np.argmax(prob[:7].numpy())].split('_')[1],
c[ np.argmax(prob[7:175].numpy())+ 7 ].split('_')[1],
c[ np.argmax(prob[175:].numpy())+ 175 ].split('_')[1] ]
sub_df = pd.DataFrame({'row_id': row_id, 'target': target})
 sub_df.to_csv('submission.csv', index=False)
 sub_df