Code repository for classifying Name-Date and Year figures in Mixtec Codices.
This repository contains three classifiers:
| Classifier | Description | Classes |
|---|---|---|
| Bead Counter | Classifies bead counts in Mixtec manuscripts | 0-15 |
| Name-Date Classifier | Distinguishes name-date vs year glyphs | 2 |
| Symbol Classifier | Classifies 20 Mixtec day sign symbols | 20 |
If you use this code in your research, please cite our paper:
@article{salunke2025classifying,
title = {Classifying Name-Date and Year Figures in Mixtec Codices},
author = {Girish Salunke and Christopher Driggers-Ellis and Christan Grant},
year = {2025},
journal = {Anthology of Computers and the Humanities},
volume = {3},
pages = {1211--1219},
editor = {Taylor Arnold, Margherita Fantoli, and Ruben Ros},
doi = {10.63744/eNge3Gj1LSHb}
}Before you begin, make sure that you have the following installed:
- uv (Python package manager)
- Git
- GPU drivers (if using GPU for training)
- Huggingface credentials (for dataset access)
- Git LFS: You might need this to ensure that the images downloaded from Huggingface are not just references but actual files.
We recommend using a GPU or a lot of patience.
The run_experiments.py script automates the full pipeline for all classifiers. You should still use the ./setup_dataset.sh scripts in each folder to download the dataset first.
# Download datasets, augment images, and train all classifiers
uv run --with loguru --with tomli --with tomli-w python run_experiments.py --setupuv run --with loguru --with tomli --with tomli-w python run_experiments.py# Only Symbol Classifier
uv run --with loguru --with tomli --with tomli-w python run_experiments.py --datasets symbol
# Bead Counter and Name-Date only
uv run --with loguru --with tomli --with tomli-w python run_experiments.py --datasets bead namedate# Skip augmentation (use existing augmented data)
uv run --with loguru --with tomli --with tomli-w python run_experiments.py --skip-augment
# Only run training
uv run --with loguru --with tomli --with tomli-w python run_experiments.py --only-train
# Only run augmentation
uv run --with loguru --with tomli --with tomli-w python run_experiments.py --only-augmentuv run --with loguru --with tomli --with tomli-w python run_experiments.py --epochs 20 --batch-size 64 --learning-rate 0.0001Preview commands without executing:
uv run --with loguru --with tomli --with tomli-w python run_experiments.py --dry-runuv run --with loguru --with tomli --with tomli-w python run_experiments.py --listTo clone the dataset from Huggingface, use the following command. You will be prompted to provide your Huggingface credentials:
./setup_dataset.shThis will download the dataset to your local system. When the huggingface user name and password are requested, you should use your Huggingface user name and token (not your password). You can create a token in your Huggingface account settings.
Each project has its own pyproject.toml file with dependencies. Navigate to the project directory and sync the environment using uv:
cd "Name-Date Classifier"
uv syncThis will create a virtual environment and install all dependencies.
Alternative (conda): You can also use the provided environment.yml file. Note that you may need to adjust the file for the GPU version of PyTorch installed on your system.
conda env create -f environment.yml
conda activate name-dateOnce the environment is set up, you can perform data augmentation on the images in the dataset. To do so, run the augment_images.py script and specify the folder path to your images dataset as a command-line argument:
uv run python augment_images.py <path_to_image_dataset>This will perform data augmentation on the images and save the results in the same directory.
To train the classification model on the augmented dataset, run the classification.py script:
uv run python classification.pyThis script will:
- Train the models on the image dataset.
- Save the trained models in the
modelsfolder. - Export accuracy and loss curves.
- Write precision, recall, and F1 score to a text file.
Each classifier has a config.toml file with training parameters:
[training]
epochs = 10
batch_size = 32
learning_rate = 0.001
[model]
seed = 42Command-line arguments to run_experiments.py override these settings temporarily during execution.
Training produces:
- Model checkpoints in classifier directory
- Training/validation metrics
- Confusion matrices and classification reports
The training script automatically detects:
- Apple MPS (Metal Performance Shaders) on macOS
- CUDA on NVIDIA GPUs
- Falls back to CPU if neither available
Special thanks to the following authors for helping with the code snippets to build vision Transformer classifiers:
- Daniel Bourke, pytorch-deep-learning
- Aarohi Singla, Image-Classification-Using-Vision-transformer
We gratefully acknowledge their contributions to the open-source community.