Closed peterzhou1520 closed 6 years ago
@peterzhou1520 这个只要维护一个数字字符到标签的映射关系,你只要按照data文件夹中的char_dict.txt文件组织你自己的数据,然后调用tools里面的脚本这个映射关系就可以自动生成。
你好,我前面就是按照char_dict.txt文件组织的,从0-9就是 0 1 2 . . 9 这种格式,生成的json文件是 {"48": "0", "49": "1", "50": "2", "51": "3", "52": "4", "53": "5", "54": "6", "55": "7", "56": "8", "57": "9"} 和 {"0": "48", "1": "49", "2": "50", "3": "51", "4": "52", "5": "53", "6": "54", "7": "55", "8": "56", "9": "57"} 但是运行失败
我试了试改了train_shadownet.py里的num_classes,按照0-9再加上一类总共11类 t = crnn_model.ShadowNet(phase='Train', hidden_nums=256, layers_nums=2, seq_length=25, num_classes=11) 现在可以训练了,是不是问题就出在这里呢。
不好意思啊,今天我在0-9的基础上加了一个字母Y,本意是用Y来代替人民币符号做数字金额的识别,生成的json文件是这样: char_dict.json:{"48": "0", "49": "1", "50": "2", "51": "3", "52": "4", "53": "5", "54": "6", "55": "7", "56": "8", "57": "9","89": "10"} ord_map.json:{"0": "48", "1": "49", "2": "50", "3": "51", "4": "52", "5": "53", "6": "54", "7": "55", "8": "56", "9": "57","10": "89"} num_classes我改成了12,然后报错了,报错信息:
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
InvalidArgumentError (see above for traceback): Saw a non-null label (index >= num_classes - 1) following a null label, batch: 1 num_classes: 12 labels: [[Node: CTCLoss = CTCLoss[ctc_merge_repeated=true, ignore_longer_outputs_than_inputs=false, preprocess_collapse_repeated=fal
请问将num_classes改成12有问题吗,该怎么改
I need to recognise only letters from a to z and numbers from 0 to 9 and nothing else. For this purpose I need to have a mapping for characters that includes only those that I need. How do I generate a char_dict.json and order_map.json? I searched for a char_dict.txt file but couldn't find it. How do I train the network to recognize only the characters that I want?
你好,我在运行的是master分支的那个项目,按照readme里说的生成了tf文件,用项目自带的.json文件可以成功训练和测试,但是我想训练这个网络只识别数字,所以用chinese_version_debug分支的tools下的establish_char_dict.py生成了char_dict.json和index_2_ord_map.json,把后者改成ord_map.json之后都放回了master分支的char_dict目录下面
生成的char_dict.json如下: {"48": "0", "49": "1", "50": "2", "51": "3", "52": "4", "53": "5", "54": "6", "55": "7", "56": "8", "57": "9"}
生成的ord_map.json如下: {"0": "48", "1": "49", "2": "50", "3": "51", "4": "52", "5": "53", "6": "54", "7": "55", "8": "56", "9": "57"}
运行train_shadownet.py之后出现了一下错误: Traceback (most recent call last): File "C:/Users/Administrator/Desktop/CRNN_Tensorflow-master/tools/train_shadownet.py", line 179, in
train_shadownet(args.dataset_dir, args.weights_path)
File "C:/Users/Administrator/Desktop/CRNN_Tensorflow-master/tools/train_shadownet.py", line 129, in train_shadownet
preds = decoder.sparse_tensor_to_str(preds[0])
File "C:\Users\Administrator\Desktop\CRNN_Tensorflow-master\local_utils\data_utils.py", line 141, in sparse_tensor_to_str
values = np.array([self.ord_map[str(tmp)] for tmp in values])
File "C:\Users\Administrator\Desktop\CRNN_Tensorflow-master\local_utils\data_utils.py", line 141, in
values = np.array([self. ord_map[str(tmp)] for tmp in values])
KeyError: '34'
最后的keyError不是固定的,还出现过'17','10','24'等数字,请问这个问题要怎么解决呢。