--- license: unlicense library_name: onnx pipeline_tag: image-classification tags: - onnx - image-classification - ritual-recognition --- # RitualCNN RitualCNN recognizes the seven ritual drawing classes used by the [Rituals game](https://github.com/methil-group/rituals). ## Use the model The ONNX file is `RitualCNN.onnx`. It accepts a grayscale image as a `float32` tensor named `input`, with shape `[batch, 1, 128, 128]`. Before inference, convert the image to grayscale, resize it to 128 by 128 pixels, set pixels above 127 to 1 and all other pixels to 0. The model returns seven raw scores named `output`. The highest score is the predicted class. The output order is: `Acervus`, `Avarus`, `Flosculus`, `Mutus`, `Not`, `Pudor`, `Regium`. ## Example predictions These are model inputs from the held-out validation set after preprocessing. When a class has no correct validation predictions, its row shows the highest-scoring example. The top softmax score is not a calibrated probability. | Input image | True label | Predicted label | Top softmax score | Result | |---|---|---|---:|---| | ![Acervus example](examples/acervus.png) | Acervus | Acervus | 19% | Correct | | ![Avarus example](examples/avarus.png) | Avarus | Avarus | 61% | Correct | | ![Flosculus example](examples/flosculus.png) | Flosculus | Flosculus | 51% | Correct | | ![Mutus example](examples/mutus.png) | Mutus | Regium | 39% | Incorrect | | ![Not example](examples/not.png) | Not | Not | 65% | Correct | | ![Pudor example](examples/pudor.png) | Pudor | Pudor | 27% | Correct | | ![Regium example](examples/regium.png) | Regium | Regium | 52% | Correct | ## Confusion matrix Rows show the true label. Columns show the predicted label. This matrix uses all 33 held-out validation images. ![Confusion matrix for the validation set](confusion_matrix.png) ## Training and evaluation The model was trained on 163 labeled source image files. A stratified 80/20 split was made by class before augmentation. Augmentation runs on the fly for training images only: rotations up to 15 degrees and translations up to 12 pixels. The split contains 130 training images and 33 validation images. 0 byte-identical duplicate groups and 0 duplicate model-input groups were found. Validation accuracy is 21/33 (63.6%); macro F1 is 59.8%. The validation set has 3 to 7 images per class. Early stopping selected epoch 47 using validation loss, so these results are for model selection rather than an independent final test. A separate flat test folder had 6 files. 2 exact duplicates were excluded, leaving 4 images from 3 classes; 3/4 were correct. This set is too small and incomplete to estimate general performance. The split is by file. The repository has no creator or session IDs for a grouped split, and drawings of the same ritual naturally look similar. Validation results are an estimate from a small dataset, not a guarantee of accuracy on new drawings. See `metrics.json` for the exact file lists, dataset fingerprint, per-class results, and ONNX compatibility checks. ## Files - `RitualCNN.onnx` — trained model, ONNX opset 11. - `config.json` — input, output, and class information. - `metrics.json` — training details and validation results. - `examples/` — validation input images shown above. - `confusion_matrix.png` — validation confusion matrix. - `README.md` — this model card. The original drawings and the game source are in the [Rituals GitHub repository](https://github.com/methil-group/rituals). The exact training split and configuration for this model are listed in `metrics.json`.