Skip to content

JDDD-hy/Calligraphy-Style-Classification

Repository files navigation

Chinese Calligraphy Style Classification 📜

zread

A deep learning project that classifies the calligraphy styles of famous Chinese calligraphers using convolutional neural networks (CNNs). This project is built with PyTorch and supports prediction via ResNet, which achieved the highest accuracy among all tested models.

📁 Dataset

  • Source: Chinese Calligraphy Styles by Calligraphers - Kaggle
  • The dataset contains images of calligraphy artworks labeled by 20 different Chinese calligraphers.
  • Each image belongs to one of the following classes: 八大山人, 褚遂良, 范文强, 管峻, 黄庭坚, 弘一, 柳公权, 梁秋生, 鲁迅, 米芾, 毛泽东, 欧阳询, 孙过庭, 宋徽宗, 沙孟海, 王羲之, 文征明, 于右人, 颜真卿, 赵孟頫
  • Images are in various styles and are used for supervised classification tasks.

🧠 Model Comparison

Three CNN models were tested to classify calligraphy styles. Final evaluation was based on validation accuracy and training efficiency.

Model Validation Accuracy Validation Loss Training Time
ResNet 96.99% 0.1055 ~10 min
VGG 94.25% 0.2114 ~14 min
LeNet 88.44% 0.3706 ~5 min

📌 Final model selected: ResNet — best overall performance in both accuracy and loss, with reasonable training time.

🚀 Project Structure

CalligraphyStyleClassification/
├── dataset/ # Dataset root folder
│ └── data/
│ ├── train/ # Training images
│ └── test/ # Testing images
├── uploads/ # Folder for input images to be classified
├── apply.py # Inference script using trained ResNet model
├── calligraphy-resnet.ipynb # Notebook for training and evaluating models
├── calligraphy_resnet.pth # Trained ResNet model weights
├── LICENSE # MIT LICENSE
├── requirements.txt # required lib
└── README.md # Project README file

📦 Installation & Usage

1. Install dependencies

Install required libraries (tested with Python 3.9):

pip install -r requirements.txt

2. Train the Model

Run calligraphy-resnet.ipynb.

This will:

  • Load and preprocess the dataset

  • Train and evaluate the model

  • Save the model to calligraphy_resnet.pth

3. Try your own images

Once the model is trained and saved, you can test custom calligraphy images:

  1. Place your test image in the uploads/ directory (e.g., uploads/my_calligraphy.png.

  2. Run the prediction script apply.py.

The console will display:

  • 🎯 Predicted calligrapher name

  • 📊 Confidence score (softmax similarity)

🤔 Future Work

This project currently focuses on backend model training and inference. Future improvements may include:

  • 🌐 Web-based Interface
    Develop a simple web application using Flask or FastAPI to allow users to upload calligraphy images and receive real-time predictions in the browser.

  • 🖼️ Image Preview and Visualization
    Integrate a frontend (e.g., with HTML + Bootstrap) to show the uploaded image, predicted label, and confidence score with visual feedback.

  • 📈 Model Performance Dashboard
    Add visual analytics using Plotly or Dash to explore model accuracy, confusion matrix, and training curves interactively.

📜 License

This project is licensed under the MIT License.
You are free to use, modify, and distribute this project with proper attribution.
See the LICENSE file for full details.

About

Calligraphy Style Classification with CNNs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published