--- language: - es - en license: cc-by-nc-nd-4.0 pipeline_tag: image-classification tags: - dinov3 - vision - body-fat-estimation - onnx - pytorch - computer-vision - healthcare - edge-ai - sports-science datasets: - MasterMIARFID/gold_label_male_torso_dataset - Sariax/MasterMIARFID_torsobf_dexa base_model: - facebook/dinov3-vitl16-pretrain-lvd1689m extra_gated_heading: "Access Request — Non-Commercial Research & Educational Use Only" extra_gated_prompt: "This model is available strictly for non-commercial academic, research, and personal educational purposes. Any commercial use, redistribution, SaaS/mobile app integration, or serving predictions via commercial APIs requires an official commercial license from the author." extra_gated_fields: Full Name: text Institution, University, or Company: text Official / Corporate Email: text Intended Use (Academic Research / Clinical Study / Commercial Licensing Inquiry): text I agree to use this model strictly for non-commercial purposes and not to redistribute weights: checkbox --- # 🧬 DINOv3 ViT-L/16 — Whole Body Fat Percentage (WBFP) Estimator

Clinical DEXA Correlation and Bland-Altman Agreement

Gated Access Non-Commercial License ONNX Runtime Commercial Inquiries

--- ## 📌 Executive Summary This repository contains the production-grade **Vision Transformer model (`39C / 39CC`)** developed as part of a Master's Thesis (TFM) at **Universitat Politècnica de València (UPV)** for the *Master's Degree in Artificial Intelligence, Pattern Recognition, and Digital Imaging (MIARFID)*. The model automatically estimates **Whole Body Fat Percentage (WBFP)** from a **single frontal RGB torso photograph** completely **offline on-device (Edge AI)**, achieving clinical agreement with hospital **Dual-Energy X-ray Absorptiometry (DEXA)** gold standards without sending biometric imagery to cloud servers (100% GDPR / HIPAA compliant by design). * **Author:** Sergi Cortés Guerrero (Universitat Politècnica de València) * **Academic Tutor:** Dr. Juan Jesús Izquierdo Doménech (DSIC / ETSINF) * **Gold Standard Reference:** Hospital DEXA Whole Body Scanners * **Test Cohort (Frozen Hold-Out):** $N = 23$ patients with clinical DEXA ground truth --- ## 🔬 Clinical Evidence & Validation (DEXA Ground Truth) The model was rigorously validated on a completely isolated, frozen clinical hold-out test set ($N=23$) with ground-truth DEXA measurements: ### 1. Correlation & Bland-Altman Agreement vs DEXA As shown in the clinical validation plot above: * **Pearson Correlation Coefficient ($r$):** **$0.92$** ($p < 0.001$, $95\%\text{ CI } [0.80, 0.98]$) * **Standard Error of Estimate (SEE / RMSE):** **$2.96\%$** (with 10x Test-Time Augmentation) / **$2.98\%$** (standard single-pass) * **Mean Absolute Error (MAE):** **$2.20\%$** (with 10x TTA) / **$2.28\%$** (standard single-pass) * **Bland-Altman 95% Limits of Agreement:** Zero systematic proportional bias across the entire physiological spectrum (from lean athletic individuals at $6\%$ to clinical obesity at $>38\%$).

DEXA Correlation

--- ### 2. Research Progression & Architectural Breakthroughs Across 119 controlled experiments, Vision Transformers fine-tuned with Low-Rank Adaptation (LoRA) and optimized via Knowledge Distillation significantly outperformed traditional ConvNets, 3D parametric morphing (SMPL), and Multimodal Large Language Models (VLLMs):

Error Reduction across R&D Phases

| Architecture / Paradigm | Description | Test SEE (%) | MAE (%) | Pearson $r$ | Clinical Assessment | | :--- | :--- | :---: | :---: | :---: | :--- | | **SMPL 3D Mesh + SVR** | 3D Body Mesh Morphing | 7.81% | 6.20% | 0.58 | Insufficient surface texture details | | **ConvNeXt-Base** | Deep Convolutional Baseline | 6.84% | 5.21% | 0.72 | Severe overfitting on small cohorts | | **Gemini 3.1 Flash (VLLM)** | Zero-shot visual prompt | 4.92% | 3.85% | 0.82 | High variance at physiological extremes | | **DINOv3 ViT-L/16 Base** | Direct Scalar MSE Regression | 4.20% | 3.30% | 0.84 | Baseline self-supervised ViT | | **Model 35-A (Distributional)** | 41-Bin Wasserstein Expected Loss | 3.75% | 2.85% | 0.88 | Captures epistemic visual uncertainty | | **Model 37-DA (Silver Curated)** | Source-Differentiated LoRA | 3.23% | 2.45% | 0.90 | High precision on high-adiposity cohorts | | **Model 39-C (Production Single)** | **Teacher-Distilled Monomodel** | **2.98%** | **2.28%** | **0.92** | **Production Single Model (This Repo)** | | **Model 39-CC (Single + TTA 10x)** | **Teacher-Distilled + 10x TTA** | **2.96%** | **2.20%** | **0.92** | **Best On-Device Single Model SOTA** | | **Ensemble HSR-3Way (Oracle)** | 3-Way Specialist Routing | **2.61%** | **1.98%** | **0.95** | **Global Benchmark Record (Enterprise Tier)** |

Complete Leaderboard

--- ## 📱 Edge AI & Mobile Deployment (100% On-Device) This model was specifically designed for **real-time on-device inference** in mobile applications without requiring internet access or cloud GPUs:

Mobile App Camera View     Mobile App Prediction and Feedback

### On-Device Hardware Benchmark (Snapdragon 8 Gen 2 / Apple A16 Bionic) | Weight Variant | Format | File Size | Size Reduction | Mobile CPU Latency | Accuracy Loss | | :--- | :---: | :---: | :---: | :---: | :---: | | `final_epoch_model.pth` | PyTorch FP32 | 1.21 GB | Baseline | ~580 ms | 0.00% (Baseline) | | `final_epoch_model_flat.onnx` | ONNX FP32 | 1.16 GB | -4.1% | ~540 ms | 0.00% (Lossless) | | `final_epoch_model_fp16.onnx` | ONNX FP16 | 581 MB | **-51.5%** | ~310 ms | < 0.01% (Undetectable) | | `final_epoch_model_selective_int8.onnx` | ONNX INT8 | **294 MB** | **-75.6%** | **~210 ms** | **< 0.05% (Clinical Grade)** | --- ## 📦 Available Files & Checkpoints All model variants are accessible upon approved gated access: * `final_epoch_model_flat.onnx` (`1.16 GB`): Self-contained single-file FP32 ONNX model compatible with `onnxruntime` on Android, iOS, Windows, Linux, and macOS. * `final_epoch_model_fp16.onnx` (`581 MB`): Half-precision FP16 ONNX model optimized for mobile GPUs and NPUs. * `final_epoch_model_selective_int8.onnx` (`294 MB`): Dynamic INT8 quantized ViT backbone with FP32 head, designed for low-memory mobile CPUs. * `final_epoch_model.pth` (`1.21 GB`): Native PyTorch FP32 weights (DINOv3 ViT-L/16 backbone + LoRA adapters + distributional head). --- ## 💻 Python Inference Example ```python import numpy as np import onnxruntime as ort from PIL import Image from huggingface_hub import hf_hub_download # 1. Download model from gated HF repository (requires approved access token) model_path = hf_hub_download( repo_id="Sariax/dinov3-body-fat-onnx", filename="final_epoch_model_flat.onnx", token="YOUR_HF_TOKEN" ) # 2. Initialize ONNX Session (CPU or CUDA) session = ort.InferenceSession(model_path) # Bin centers from 5.0% to 45.0% (41 continuous bins) bin_centers = np.linspace(5.0, 45.0, 41) # 3. Preprocess Image (224x224, ImageNet Normalized NCHW) def preprocess(image_path): img = Image.open(image_path).convert('RGB').resize((224, 224)) arr = np.array(img).astype(np.float32) / 255.0 mean = np.array([0.485, 0.456, 0.406], dtype=np.float32) std = np.array([0.229, 0.224, 0.225], dtype=np.float32) norm = (arr - mean) / std tensor = np.transpose(norm, (2, 0, 1)) # HWC -> CHW return np.expand_dims(tensor, axis=0) # Add batch dim -> [1, 3, 224, 224] # 4. Predict Softmax Distribution input_tensor = preprocess("torso_photo.jpg") logits = session.run(None, {"input": input_tensor})[0] probabilities = np.exp(logits - np.max(logits)) / np.sum(np.exp(logits - np.max(logits))) # 5. Compute Mathematical Expectation (WBFP) estimated_wbfp = np.sum(probabilities * bin_centers) uncertainty_std = np.sqrt(np.sum(probabilities * ((bin_centers - estimated_wbfp) ** 2))) print(f"Estimated Body Fat: {estimated_wbfp:.2f}% (Visual Uncertainty: ±{uncertainty_std:.2f}%)") ``` --- ## 💼 Commercial Licensing, Partnerships & Consulting ### Licensing Overview | Tier | Target Audience | Permitted Use | Access | | :--- | :--- | :--- | :--- | | **Academic & Personal** | Students, Academic Researchers | Non-commercial research, thesis validation, open science | **Free** via Gated Access (CC BY-NC-ND 4.0) | | **Commercial Startup / App** | Fitness Apps, Telemedicine, Smart Scales | Mobile/Web apps, SaaS products, freemium services | **Commercial License Agreement** | | **Enterprise Clinical Tier** | Hospitals, Insurances, Healthtech Giants | Full **Oracle Ensemble (SEE 2.61%)** + Cloud / Edge deployment | **Enterprise Partnership** | ### Prohibited Without Commercial Agreement Any commercial deployment, bundling into paid or ad-supported apps, serving predictions through commercial APIs, or redistribution of weights without a signed commercial agreement is strictly prohibited under the **Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)** license. ### Commercial Inquiries & Custom Development If you or your company wish to: 1. **Acquire a commercial license** for the on-device production model. 2. **Access the Oracle Ensemble 3-Way HSR system** (benchmark record: **SEE 2.61%, MAE 1.98%, Pearson $r = 0.95$**). 3. **Commission custom engineering:** Mobile app integration (Flutter, Swift, Kotlin), camera-guided alignment, calibration on female/athletic cohorts, or enterprise cloud deployment. 👉 **How to contact:** * **Hugging Face:** Open a formal inquiry in the [Discussions tab](https://huggingface.co/Sariax/dinov3-body-fat-onnx/discussions). * **Direct Contact:** Contact the author **Sergi Cortés Guerrero** directly via Hugging Face profile or through the contact details provided upon gated access approval. --- ## 📚 Citation If you use this model or refer to its methodology in academic work, please cite: ```bibtex @mastersthesis{cortes2026bodyfat, title = {Estimaci{\'o}n del porcentaje de grasa corporal mediante modelos de visi{\'o}n multimodal y despliegue en dispositivos m{\'o}viles}, author = {Cort{\'e}s Guerrero, Sergi}, school = {Universitat Polit{\`e}cnica de Val{\`e}ncia (UPV)}, year = {2026}, type = {Master's Thesis}, address = {Valencia, Spain} } ```