Package: batukh
batukhDetection of Languages using CRNN.InstallationUsingpipFor tensorflow only installation:pip install batukh[tf]For pytorch only installation:pip install batukh[torch]For tensorflow and pytorch installation:pip install batukh[full]:heavy_exclamation_mark:Warning:A simplepip install batukhwill install neither tensorflow nor pytorch dependencies.TrainingAfter all the dependencies have been installed, you can train any model.For Page Extraction(tensorflow):>>>frombatukh.tensorflow.segmenterimportPageExtractor>>>page_extractor=PageExtractor()>>>page_extractor.load_data("/path/to/data/")>>>page_extractor.train(n_epochs=10,batch_size=1,repeat=1)InitializingfromscratchEpoch:1.Traininig:100%|██████████|70/70[00:02<00:00,23.95it/s,loss=0.0708]Epoch:2.Traininig:100%|██████████|70/70[00:02<00:00,24.35it/s,loss=0.0682]Modelsavedto/content/tf_ckpts/FriOct1608:23:132020/ckpt-14280Epoch:3.Traininig:100%|██████████|70/70[00:02<00:00,23.69it/s,loss=0.0658]Epoch:4.Traininig:100%|██████████|70/70[00:02<00:00,24.74it/s,loss=0.0636]Modelsavedto/content/tf_ckpts/FriOct1608:23:132020/ckpt-14420Epoch:5.Traininig:100%|██████████|70/70[00:02<00:00,23.68it/s,loss=0.0616]Epoch:6.Traininig:100%|██████████|70/70[00:02<00:00,23.95it/s,loss=0.0597]Modelsavedto/content/tf_ckpts/FriOct1608:23:132020/ckpt-14560Epoch:7.Traininig:100%|██████████|70/70[00:03<00:00,23.24it/s,loss=0.0579]Epoch:8.Traininig:100%|██████████|70/70[00:03<00:00,23.23it/s,loss=0.0563]Modelsavedto/content/tf_ckpts/FriOct1608:23:132020/ckpt-14700Epoch:9.Traininig:100%|██████████|70/70[00:02<00:00,23.44it/s,loss=0.0548]Epoch:10.Traininig:100%|██████████|70/70[00:02<00:00,23.54it/s,loss=0.0533]Modelsavedto/content/tf_ckpts/FriOct1608:23:132020/ckpt-14840For OCR(tensorflow):>>>frombatukh.tensorflow.ocrimportOCR>>>m=OCR()>>>m.load_data("/path/to/data")>>>m.train(10,batch_size=1,repeat=1)InitializingfromscratchEpoch:1.Traininig:100%|██████████|70/70[00:04<00:00,15.84it/s,loss=37.1]Epoch:2.Traininig:100%|██████████|70/70[00:02<00:00,23.57it/s,loss=29.7]Modelsavedtotf_ckpts/FriOct1609:44:352020/ckpt-140Epoch:3.Traininig:100%|██████████|70/70[00:02<00:00,24.01it/s,loss=26.8]Epoch:4.Traininig:100%|██████████|70/70[00:02<00:00,23.84it/s,loss=25.3]Modelsavedtotf_ckpts/FriOct1609:44:352020/ckpt-280Epoch:5.Traininig:100%|██████████|70/70[00:02<00:00,23.46it/s,loss=24.4]Epoch:6.Traininig:100%|██████████|70/70[00:02<00:00,24.33it/s,loss=23.8]Modelsavedtotf_ckpts/FriOct1609:44:352020/ckpt-420Epoch:7.Traininig:100%|██████████|70/70[00:02<00:00,23.96it/s,loss=23.3]Epoch:8.Traininig:100%|██████████|70/70[00:02<00:00,23.67it/s,loss=22.9]Modelsavedtotf_ckpts/FriOct1609:44:352020/ckpt-560Epoch:9.Traininig:100%|██████████|70/70[00:03<00:00,23.22it/s,loss=22.6]Epoch:10.Traininig:100%|██████████|70/70[00:02<00:00,23.52it/s,loss=22.3]Modelsavedtotf_ckpts/FriOct1609:44:352020/ckpt-700For Baseline Detection(pytorch):>>>frombatukh.torch.segmenterimportBaselineDetector>>>m=BaselineDetector()<Allkeysmatchedsuccessfully>>>>m.load_data("/path/to/data")>>>m.train(n_epochs=10,device="cpu")For OCR(pytorch):>>>frombatukh.torch.ocrimportOCR>>>m=OCR()>>>m.load_data("/path/to/train_dir","/path/to/train_labels","/path/to/val_dir","/path/to/val_labels")BuildingDictionary...BuildingDictionary...>>>m.train(5)Epoch:0.Traininig:100%|███████████████|140/140[00:04<00:00,30.18it/s,loss=2.59]Epoch:0.Validating:100%|███████████████|140/140[00:01<00:00,112.06it/s,loss=2.59]ModelsSaved!Epoch:1.Traininig:100%|███████████████|140/140[00:04<00:00,32.39it/s,loss=2.36]Epoch:1.Validating:100%|███████████████|140/140[00:01<00:00,121.36it/s,loss=2.18]ModelsSaved!Epoch:2.Traininig:100%|███████████████|140/140[00:04<00:00,31.12it/s,loss=2.54]Epoch:2.Validating:100%|███████████████|140/140[00:01<00:00,108.65it/s,loss=2.48]ModelsSaved!Epoch:3.Traininig:100%|███████████████|140/140[00:04<00:00,31.10it/s,loss=2.48]Epoch:3.Validating:100%|███████████████|140/140[00:01<00:00,109.46it/s,loss=2.42]ModelsSaved!Epoch:4.Traininig:100%|███████████████|140/140[00:04<00:00,30.17it/s,loss=2.49]Epoch:4.Validating:100%|███████████████|140/140[00:01<00:00,110.09it/s,loss=2.42]ModelsSaved!