Git Product home page Git Product logo

bengali.ai-handwritten-character-recognition-challenge's Introduction

Bengali.ai Handwritten Character Recognition Challenge: 100-ish solution(?)

My scripts for the Bengali.ai handwritten character Recognition challenge 2019. Although I could not submit the final trained models within the competition deadline, later I found out that it would get me a 100-ish private Leadeboard position.

I added customized 1 channel input seresext, densenet, efficientnet and ghostnet models in this repo.

My Method:

  • Trained each model for around 100 epochs with OHEM cross-entropy loss.
  • Trained the first 30 epochs with rate=1 for OHEM loss. Then gradually decreased the rate to 0.65 over the next 35 epochs. This approach significantly increased my Grapheme recall.
  • Applied CutOut, CutMix and Mixup augmentations.
  • Used heavy augmentations during training se-resnext101 model.

Things that works:

  • SE-Resnext50
  • CutMix + MixUp
  • OHEM Loss
  • Gem (Did not compare with AvgPool)
  • Mish (Did not compare with ReLU)
  • Training for longer epochs and no early stopping
  • Rely on validation loss rather than recall score.

Things that may work:

  • AugMix
  • EfficientNet with customized last Convolutional Layer
  • SE-Resnext101 (Teacher-Student model)
  • Focal Loss with EfficientNet-B4

Important Discussions:

Resources:

def gem(x, p=3, eps=1e-6):
    x = x.double() # x=x.to(torch.float32) # comment this during inference
    x = F.avg_pool2d(x.clamp(min=eps).pow(p), (x.size(-2), x.size(-1))).pow(1./p)
    return x.half() # Comment this line in inference code use ## return x

class GeM(nn.Module):
    def init(self, p=3, eps=1e-6):
        super(GeM,self).init()
        # super().init()
        self.p = Parameter(torch.ones(1)*p)
        # print(self.p.dtype)
        self.eps = eps
    def forward(self, x):
        return gem(x, p=self.p, eps=self.eps)
    def repr(self):
        return self.class.name + '(' + 'p=' + '{:.4f}'.format(self.p.data.tolist()[0]) + ', ' + 'eps=' + str(self.eps) + ')'

How to run

  • Run pip install -r requirements.txt
  • Run train.py

Credits

Thanks to the kaggle community for sharing a lot of resources and making the tasks easier for us. Here is a list of discussions from where I've borrowed codes and/or became inspired to write codes:

More resources will be added soon.

bengali.ai-handwritten-character-recognition-challenge's People

Contributors

tahsin314 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.