Commit 479f9de1 authored by Cao Duc Anh's avatar Cao Duc Anh

reupdate

parent 7a3e3b97
# change to list chars of your dataset or use default vietnamese chars
vocab: 'aAàÀảẢãÃáÁạẠăĂằẰẳẲẵẴắẮặẶâÂầẦẩẨẫẪấẤậẬbBcCdDđĐeEèÈẻẺẽẼéÉẹẸêÊềỀểỂễỄếẾệỆfFgGhHiIìÌỉỈĩĨíÍịỊjJkKlLmMnNoOòÒỏỎõÕóÓọỌôÔồỒổỔỗỖốỐộỘơƠờỜởỞỡỠớỚợỢpPqQrRsStTuUùÙủỦũŨúÚụỤưƯừỪửỬữỮứỨựỰvVwWxXyYỳỲỷỶỹỸýÝỵỴzZ0123456789!"#$%&''()*+,-./:;<=>?@[\]^_`{|}~ '
# cpu, cuda, cuda:0
device: cuda:0
seq_modeling: transformer
transformer:
d_model: 256
nhead: 8
num_encoder_layers: 6
num_decoder_layers: 6
dim_feedforward: 2048
max_seq_length: 1024
pos_dropout: 0.1
trans_dropout: 0.1
optimizer:
max_lr: 0.0003
pct_start: 0.1
trainer:
batch_size: 32
print_every: 200
valid_every: 4000
iters: 100000
# where to save our model for prediction
export: ./weights/transformerocr.pth
checkpoint: ./checkpoint/transformerocr_checkpoint.pth
log: ./train.log
# null to disable compuate accuracy, or change to number of sample to enable validiation while training
metrics: null
dataset:
# name of your dataset
name: data
# path to annotation and image
data_root: ./img/
train_annotation: annotation_train.txt
valid_annotation: annotation_val_small.txt
# resize image to 32 height, larger height will increase accuracy
image_height: 32
image_min_width: 32
image_max_width: 512
dataloader:
num_workers: 3
pin_memory: True
aug:
image_aug: true
masked_language_model: true
predictor:
# disable or enable beamsearch while prediction, use beamsearch will be slower
beamsearch: False
quiet: False
\ No newline at end of file
pretrain:
id_or_url: 1nTKlEog9YFK74kPyX0qLwCWi60_YHHk4
md5: efcabaa6d3adfca8e52bda2fd7d2ee04
cached: /tmp/tranformerorc.pth
# url or local path
weights: https://drive.google.com/uc?id=1nTKlEog9YFK74kPyX0qLwCWi60_YHHk4
backbone: vgg19_bn
cnn:
# pooling stride size
ss:
- [2, 2]
- [2, 2]
- [2, 1]
- [2, 1]
- [1, 1]
# pooling kernel size
ks:
- [2, 2]
- [2, 2]
- [2, 1]
- [2, 1]
- [1, 1]
# dim of ouput feature map
hidden: 256
seq_modeling: seq2seq
transformer:
encoder_hidden: 256
decoder_hidden: 256
img_channel: 256
decoder_embedded: 256
dropout: 0.1
optimizer:
max_lr: 0.001
pct_start: 0.1
\ No newline at end of file
# for training
pretrain: https://vocr.vn/data/vietocr/vgg_transformer.pth
# url or local path (predict)
weights: https://vocr.vn/data/vietocr/vgg_transformer.pth
backbone: vgg19_bn
cnn:
pretrained: True
# pooling stride size
ss:
- [2, 2]
- [2, 2]
- [2, 1]
- [2, 1]
- [1, 1]
# pooling kernel size
ks:
- [2, 2]
- [2, 2]
- [2, 1]
- [2, 1]
- [1, 1]
# dim of ouput feature map
hidden: 256
seq_modeling: transformer
transformer:
encoder_hidden: 256
decoder_hidden: 256
img_channel: 256
decoder_embedded: 256
dropout: 0.1
optimizer:
max_lr: 0.001
pct_start: 0.1
\ No newline at end of file
......@@ -214,7 +214,7 @@
" im = cv2.copyMakeBorder(im, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # add border\n",
" return im, r, (dw, dh)\n",
"\n",
"names = ['id', 'name', 'birth', 'sex', 'nation', 'origin', 'origin1', 'r1', 'r2']\n",
"names = [\"birth\", \"id\", \"name\", \"nation\", \"origin\", \"origin1\", \"r1\", \"r2\", \"sex\"]\n",
"colors = {name:[random.randint(0, 255) for _ in range(3)] for i,name in enumerate(names)}\n",
"\n",
"img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n",
......
......@@ -366,9 +366,9 @@
"metadata": {},
"outputs": [],
"source": [
"model_cnn = torch.jit.load(\"/home/anhcd/Projects/dac_vietocr/ConvertVietOcr2Onnx/weight/cnn.cpu.torchscript\").to(device)\n",
"model_encoder = torch.jit.load(\"/home/anhcd/Projects/dac_vietocr/ConvertVietOcr2Onnx/weight/encoder.cpu.torchscript\").to(device)\n",
"model_decoder = torch.jit.load(\"/home/anhcd/Projects/dac_vietocr/ConvertVietOcr2Onnx/weight/decoder.cpu.torchscript\").to(device)"
"model_cnn = torch.jit.load(\"/home/anhcd/Projects/dac_vietocr/ConvertVietOcr2Onnx/weight/cnn.torchscript\").to(device)\n",
"model_encoder = torch.jit.load(\"/home/anhcd/Projects/dac_vietocr/ConvertVietOcr2Onnx/weight/encoder.torchscript\").to(device)\n",
"model_decoder = torch.jit.load(\"/home/anhcd/Projects/dac_vietocr/ConvertVietOcr2Onnx/weight/decoder.torchscript\").to(device)"
]
},
{
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment