Chinese Handwriting Recognition โ HSK1
A CNN trained on the HWDB1.0 dataset to recognise 178 Chinese characters.
Model details
| Item |
Value |
| Input |
40ร40 grayscale image |
| Classes |
178 Chinese characters + Unknown |
| Framework |
Keras / TensorFlow |
| Confidence threshold |
0.5 (below โ Unknown) |
Files
| File |
Description |
chinese_hsk1_model.keras |
Trained Keras model |
label_map.json |
Index-to-character mapping |
training_curves.png |
Accuracy & loss curves |
Quick start
import numpy as np, json
from tensorflow import keras
model = keras.models.load_model('chinese_hsk1_model.keras')
label_map = json.load(open('label_map.json', encoding='utf-8'))
THRESHOLD = 0.5
def predict(img_40x40_gray):
x = img_40x40_gray.astype('float32') / 255.0
x = x.reshape(1, 40, 40, 1)
probs = model.predict(x)[0]
conf = probs.max()
if conf < THRESHOLD:
return 'Unknown', conf
return label_map[str(probs.argmax())], conf