Instructions to use ERO26/fetal-planes-classification-custom-cnn-V2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ERO26/fetal-planes-classification-custom-cnn-V2 with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ERO26/fetal-planes-classification-custom-cnn-V2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
fetal-planes-classification-custom-cnn-V2
This model was trained from scratch on ERO26/fetal-planes-classification-zenodo.
It achieves the following results on the evaluation set:
- Loss: 0.3325
- Accuracy: 0.8925
- Precision Macro: 0.8655
- Recall Macro: 0.8859
- F1 Macro: 0.8750
Model description
- Developed by: ERO26
- Model Type: Custom Convolutional Neural Network (CNN) for Image Classification
- Task: Multi-class classification of standard fetal ultrasound planes
- Input: Grayscale ultrasound images resized to 128x128 pixels ((1, 128, 128)) tensor format
- Output: Probability logits across the target fetal plane classes
- Architecture Highlights:
- Feature Extractor: 3 Conv2d blocks (32, 64, and 128 channels) with
BatchNorm2d,ReLU,MaxPool2d, andDropout2d. - Classifier Head: Flatten layer, linear projection to 256 hidden units with ReLU and 50% dropout, followed by a final linear layer matching
num_classes.
- Feature Extractor: 3 Conv2d blocks (32, 64, and 128 channels) with
- Loss Function: Cross-Entropy Loss with integrated class weights to handle dataset imbalance.
Intended uses & limitations
Intended Uses
- Clinical Quality Assurance: Assisting sonographers and medical researchers in automatically tagging or verifying standard fetal imaging planes during routine or archive scans.
- Educational Tool: Supporting medical students and trainees in learning standard fetal biometric and anatomical plane identification.
Limitations & Out-of-Scope Use
- Not a Diagnostic Device: This model is intended for research, educational, and assistive prototyping purposes only. It must not be deployed as a standalone diagnostic tool for clinical decision-making.
- Domain Shift: Performance may degrade when evaluating ultrasound images captured using scanner hardware, acoustic settings, or transducers significantly different from the training distribution.
Training and evaluation data
- Dataset: Trained on
ERO26/fetal-planes-classification-zenodo. - Data Splits: The dataset is partitioned into training, validation, and test subsets to ensure robust generalization and unbiased final evaluation.
- Preprocessing: Images are normalized, converted to single-channel grayscale, and uniformly resized to 128x128 pixels before being ingested into the network pipeline.
Training procedure
The model was trained from scratch using the Hugging Face Trainer framework with native Automatic Mixed Precision (AMP) enabled for accelerated convergence. Class frequency imbalances were addressed by incorporating dynamically calculated class weights into the loss function.
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 0.001
- train_batch_size: 4
- eval_batch_size: 16
- seed: 42
- gradient_accumulation_steps: 4
- total_train_batch_size: 16
- optimizer: Use
OptimizerNames.ADAMW_TORCH_FUSEDwith betas=(0.9, 0.999) and epsilon=1e-08 - lr_scheduler_type: cosine
- num_epochs: 50
- mixed_precision_training: Native AMP
Training results
| Training Loss | Epoch | Step | Validation Loss | Accuracy | Precision Macro | Recall Macro | F1 Macro |
|---|---|---|---|---|---|---|---|
| 1.3456 | 1.0 | 483 | 1.0316 | 0.6154 | 0.5400 | 0.5902 | 0.5513 |
| 1.1372 | 2.0 | 966 | 0.8518 | 0.7083 | 0.5991 | 0.6207 | 0.6050 |
| 1.1105 | 3.0 | 1449 | 0.8140 | 0.6853 | 0.6885 | 0.6511 | 0.6033 |
| 0.9768 | 4.0 | 1932 | 0.7625 | 0.7418 | 0.6974 | 0.6790 | 0.6538 |
| 0.9741 | 5.0 | 2415 | 0.6964 | 0.7709 | 0.7395 | 0.7428 | 0.7405 |
| 0.9589 | 6.0 | 2898 | 0.6519 | 0.7774 | 0.7346 | 0.8025 | 0.7556 |
| 0.9560 | 7.0 | 3381 | 0.6211 | 0.7923 | 0.7692 | 0.8018 | 0.7771 |
| 1.0999 | 8.0 | 3864 | 0.6459 | 0.7802 | 0.7682 | 0.7745 | 0.7642 |
| 0.7949 | 9.0 | 4347 | 0.6083 | 0.7774 | 0.7506 | 0.8030 | 0.7639 |
| 0.9959 | 10.0 | 4830 | 0.5928 | 0.7907 | 0.7691 | 0.8160 | 0.7817 |
| 0.9712 | 11.0 | 5313 | 0.6226 | 0.8121 | 0.7907 | 0.7757 | 0.7824 |
| 0.8147 | 12.0 | 5796 | 0.6095 | 0.7798 | 0.7539 | 0.7963 | 0.7599 |
| 1.0257 | 13.0 | 6279 | 0.5274 | 0.8145 | 0.7740 | 0.8428 | 0.7949 |
| 0.7305 | 14.0 | 6762 | 0.5366 | 0.8210 | 0.7859 | 0.8458 | 0.8046 |
| 0.8411 | 15.0 | 7245 | 0.5289 | 0.8473 | 0.8116 | 0.8383 | 0.8230 |
| 0.8429 | 16.0 | 7728 | 0.5153 | 0.8356 | 0.7968 | 0.8489 | 0.8152 |
| 0.7142 | 17.0 | 8211 | 0.5005 | 0.8246 | 0.7845 | 0.8463 | 0.8057 |
| 0.8082 | 18.0 | 8694 | 0.4856 | 0.8384 | 0.7954 | 0.8629 | 0.8153 |
| 0.8288 | 19.0 | 9177 | 0.4598 | 0.8440 | 0.8060 | 0.8619 | 0.8260 |
| 0.6925 | 20.0 | 9660 | 0.4633 | 0.8448 | 0.8168 | 0.8477 | 0.8261 |
| 0.6559 | 21.0 | 10143 | 0.4106 | 0.8574 | 0.8219 | 0.8694 | 0.8405 |
| 0.9501 | 22.0 | 10626 | 0.4358 | 0.8497 | 0.8224 | 0.8520 | 0.8321 |
| 0.7521 | 23.0 | 11109 | 0.4334 | 0.8590 | 0.8248 | 0.8637 | 0.8407 |
| 0.6465 | 24.0 | 11592 | 0.4282 | 0.8622 | 0.8340 | 0.8621 | 0.8454 |
| 0.7596 | 25.0 | 12075 | 0.4136 | 0.8655 | 0.8349 | 0.8727 | 0.8507 |
| 0.7067 | 26.0 | 12558 | 0.3887 | 0.8541 | 0.8175 | 0.8842 | 0.8404 |
| 0.6809 | 27.0 | 13041 | 0.3910 | 0.8687 | 0.8360 | 0.8758 | 0.8524 |
| 0.7512 | 28.0 | 13524 | 0.4133 | 0.8469 | 0.8127 | 0.8611 | 0.8280 |
| 0.6192 | 29.0 | 14007 | 0.3734 | 0.8711 | 0.8461 | 0.8703 | 0.8533 |
| 0.7913 | 30.0 | 14490 | 0.3547 | 0.8772 | 0.8499 | 0.8732 | 0.8593 |
| 0.5643 | 31.0 | 14973 | 0.3568 | 0.8832 | 0.8591 | 0.8780 | 0.8648 |
| 0.5899 | 32.0 | 15456 | 0.3485 | 0.8828 | 0.8579 | 0.8834 | 0.8684 |
| 0.5222 | 33.0 | 15939 | 0.3339 | 0.8877 | 0.8564 | 0.8898 | 0.8705 |
| 0.4918 | 34.0 | 16422 | 0.3325 | 0.8925 | 0.8655 | 0.8859 | 0.8750 |
| 0.4758 | 35.0 | 16905 | 0.3389 | 0.8877 | 0.8608 | 0.8885 | 0.8731 |
| 0.6259 | 36.0 | 17388 | 0.3396 | 0.8885 | 0.8642 | 0.8817 | 0.8720 |
| 0.5672 | 37.0 | 17871 | 0.3331 | 0.8893 | 0.8666 | 0.8842 | 0.8743 |
| 0.5458 | 38.0 | 18354 | 0.3363 | 0.8861 | 0.8621 | 0.8881 | 0.8728 |
| 0.4549 | 39.0 | 18837 | 0.3226 | 0.8865 | 0.8601 | 0.8865 | 0.8717 |
Framework versions
- Transformers 5.17.0
- Pytorch 2.11.0+cu128
- Datasets 5.0.1
- Tokenizers 0.23.1
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support