-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.py
42 lines (31 loc) · 2.48 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) 2017 May
#!_*_coding:UTF-8_*_
#中国七位字符车牌识别,34汉字+10数字+24字母=68
#中国车牌没有I和O
import numpy
__all__ = (
# 'DIGITS',
# 'LETTERS',
'CHARS')
# chars = ["京", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "警", "使", "学", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X","Y", "Z"]
# WORD = "京沪津渝冀晋蒙辽吉黑苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云藏陕甘青宁新警使学"
# DIGITS = "0123456789"
# LETTERS = "ABCDEFGHJKLMNPQRSTUVWXYZ"
# CHARS = WORD + DIGITS + LETTERS
index_show = {"京": 0, "沪": 1, "津": 2, "渝": 3, "冀": 4, "晋": 5, "蒙": 6, "辽": 7, "吉": 8, "黑": 9, "苏": 10, "浙": 11, "皖": 12,"闽": 13, "赣": 14, "鲁": 15,
"豫": 16, "鄂": 17, "湘": 18, "粤": 19, "桂": 20, "琼": 21, "川": 22, "贵": 23, "云": 24,"藏": 25, "陕": 26, "甘": 27, "青": 28, "宁": 29, "新": 30,
"警":31, "使":32, "学":33, "0": 34, "1": 35, "2": 36, "3": 37, "4": 38, "5": 39,"6": 40, "7": 41, "8": 42, "9": 43, "A": 44, "B": 45, "C": 46,
"D": 47, "E": 48, "F": 49, "G": 50, "H": 51,"J": 52, "K": 53, "L": 54, "M": 55, "N": 56, "P": 57, "Q": 58, "R":59, "S": 60, "T": 61, "U": 62,
"V": 63,"W": 64, "X": 65, "Y": 66, "Z": 67}
show_index={0: "京", 1: "沪", 2: "津", 3: "渝", 4: "冀", 5: "晋", 6: "蒙", 7: "辽", 8: "吉", 9: "黑", 10: "苏", 11: "浙", 12: "皖",13: "闽", 14: "赣", 15: "鲁",
16: "豫", 17: "鄂", 18: "湘", 19: "粤", 20: "桂", 21: "琼", 22: "川", 23: "贵", 24: "云", 25: "藏", 26: "陕", 27: "甘", 28: "青", 29: "宁", 30: "新",
31: "警", 32: "使", 33: "学", 34: "0", 35: "1", 36: "2", 37: "3", 38: "4", 39: "5",40: "6", 41: "7", 42: "8", 43: "9", 44: "A", 45: "B", 46: "C",
47: "D", 48: "E", 49: "F", 50: "G", 51: "H",52: "J", 53: "K", 54: "L", 55: "M", 56: "N", 57: "P", 58: "Q",59 :"R", 60: "S", 61: "T", 62: "U",
63: "V",64: "W", 65: "X", 66: "Y", 67: "Z"}
# print show_index
num_class=len(index_show) #68
def softmax(a):
exps = numpy.exp(a.astype(numpy.float64))
return exps / numpy.sum(exps, axis=-1)[:, numpy.newaxis]
def sigmoid(a):
return 1. / (1. + numpy.exp(-a))