Kaggle competition: Cassava Leaf Disease Classification
<SOS> metric: CategorizationAccuracy Kaggle data source: cassava-leaf-disease-classification<load_pretrained>
sys.path.append('.. /input/timm-pytorch-image-models/pytorch-image-models-master')
 TESTSAMPLEPATH = '.. /input/cassava-leaf-disease-classification/sample_submission.csv'
CLASSESJSONPATH = '.. /input/cassava-leaf-disease-classification/label_num_to_disease_map.json'
TESTDATAPATH = '.. /input/cassava-leaf-disease-classification/test_images'
TRAINDATAPATH = '.. /input/cassava-leaf-disease-classification/train_images'
cfg = {}
cfg['image_size'] = 512
cfg['device'] = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
 cfg['batch_size'] = 16
classes = {}
num_class = 0
with open(CLASSESJSONPATH)as f:
classes = json.load(f)
 num_class = len(classes)
 def readImage(ID, path):
ID = ID.split('.')[0]
filepath = os.path.join(path, ID + '.jpg')
 img = cv2.imread(filepath)
 img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
 return img
facedet = BlazeFace().to(gpu)
 facedet.load_weights("/kaggle/input/blazeface-pytorch/blazeface.pth")
 facedet.load_anchors("/kaggle/input/blazeface-pytorch/anchors.npy")
 _ = facedet.train(False )<load_pretrained>
class CLCdataset(Dataset):
def __init__(self, df,isTrain = True):
self.df = df
self.isTrain = isTrain
def __len__(self):
return len(self.df)
 def __getitem__(self, idx):
ID = self.df['image_id'].iloc[idx].split('.')[0]
img = readImage(ID, TRAINDATAPATH if self.isTrain else TESTDATAPATH)
 if self.isTrain:
img = train_transform(image = img)['image']
else:
img = test_transform(image = img)['image']
if self.isTrain:
label = self.df['label'].iloc[idx]
return ID, img, label
return ID, img
frames_per_video = 20
video_reader = VideoReader()
video_read_fn = lambda x: video_reader.read_frames(x, num_frames=frames_per_video)
 face_extractor = FaceExtractor(video_read_fn, facedet )<define_variables>
test_transform = A.Compose([
A.Resize(cfg['image_size'], cfg['image_size'],p=1),
A.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], max_pixel_value=255.0, p=1.0),
ToTensorV2()
] )
<normalization><EOS> 
class CFCmodel(nn.Module):
def __init__(self, out_dim):
super(CFCmodel, self ).__init__()
self.model = timm.create_model('efficientnet_b3', pretrained=False)
 self.model.classifier = nn.Linear(in_features=1536,out_features=out_dim, bias=True)
 self.model.eval()
def forward(self, input):
return self.model(input )