Alle artikelen

AI-engineering

YOLO on Databricks: From Kaggle Notebook to Governed Training

Move a YOLO experiment from Kaggle to governed Databricks training with versioned image data, MLflow tracking, GPU checks and controlled model deployment.

  • PyTorch
  • MLflow
  • Databricks
  • Unity Catalog
  • Ultralytics
  • Kaggle

A YOLO notebook that works on Kaggle answers one question: can this training code produce a useful detector? An organisational platform raises different questions. Who can access the images, which dataset produced the weights, and how will the next model replace the current one?

We treat computer vision as a platform workload, not just a GPU experiment. It needs ownership, reproducibility and deployment discipline. An accelerator does not remove those requirements.

This guide covers governed images, a single-GPU baseline, recorded experiments and a tested inference contract. We distinguish classic Azure GPU compute from AI Runtime, Databricks’ serverless GPU offering, and explain when keeping the experiment on Kaggle is better. Personal notebooks leave lifecycle controls undefined; we recommend governed training, so establish versioned inputs and release gates before moving YOLO into production.

The Short Version

The difficult part of moving a detector is rarely copying the training cell. A personal notebook can hide mutable datasets, undocumented package changes and checkpoints whose provenance nobody can reconstruct. We start with governed, versioned inputs and a measured single-GPU baseline. Tracking, model packaging and production approval remain separate responsibilities.

How It Works

Object detection identifies objects and their positions in an image, usually as labelled bounding boxes. Training pairs images with annotations and a consistent class mapping; fine-tuning adapts pretrained parameters to the target classes and visual conditions.

For most organisational workloads, we start with reviewed pretrained weights rather than random parameters. Training from scratch usually demands more data and experimentation, but unsuitable weight provenance or poor transfer to the target imagery can justify it.

Databricks publishes a YOLO11n computer-vision example using COCO128, serverless GPU, MLflow tracking and Model Serving deployment. That is an integration reference on the AWS documentation site. It does not establish Azure compatibility or detector quality on your images.

The Azure AI Runtime overview recommends AI Runtime for custom deep-learning training workloads. We would evaluate it first when workspace eligibility and processing geography are acceptable, while keeping classic GPU compute as a deliberate alternative.

Hands-On

1. Prepare a governed dataset release

Provision dataset and artefact volumes through NexOps-managed Terraform modules, for example cv_dev.inspection.images and cv_dev.inspection.model_artifacts. Define ownership and human access through account-synchronised Entra ID groups in Terraform. Give the training service principal only required input and output permissions. Test that unrelated datasets remain inaccessible.

  1. Classify images before loading them.
  2. Record the processing purpose, data owner and retention period.
  3. Remove or mask unnecessary personal data.
  4. Split images into training, validation and held-out test sets before tuning.
  5. Keep near-identical photographs, neighbouring video frames and images of the same shipment in the same split.

Create a release manifest containing image identifiers, annotation revisions, split assignments and checksums. Freeze that release through permissions and change controls. A release directory name alone does not prevent someone changing its contents.

An illustrative layout is:

release_001/
  data.yaml
  images/
    train/
    val/
    test/
  labels/
    train/
    val/
    test/
  manifest.json

This layout keeps the dataset configuration, image splits, annotations and release evidence together. The directories are an organisational example, not a complete specification of the selected loader’s annotation format.

Treat the dataset configuration as part of the versioned loader contract. Record the selected Ultralytics release and its expected image locations, annotation format and class mapping.

Check the selected release against the official Ultralytics detection dataset guide. The supplied sources do not establish its exact YAML fields or label-file rules. This layout therefore illustrates organisation, not a validated loader configuration.

Validate image readability, annotation completeness, box geometry and class consistency before allocating GPU time. Document how intentionally unannotated or background images are represented so the validator does not confuse them with annotation failures.

EnvironmentData and execution policy
devSynthetic, masked or anonymised samples; engineer experimentation
testFixed synthetic, masked or anonymised fixtures; automated loader and inference-contract tests
accRepresentative approved data; operational evaluation and access tests
prdApproved releases; controlled training and promotion identities

Version the deployment machinery too. Our Databricks bundle guide covers configuration and CI/CD discipline. Keep business logic in Python packages and notebooks thin.

  1. Define separate bundle targets and resources for dev, test, acc and prd.
  2. Deploy jobs through CI/CD with workload identity federation and a service-principal run_as identity.
  3. Set bundle permissions through groups.
  4. Build the artefact once.
  5. Promote it through pull requests from dev to test, acc and main, which deploys to prd.
  6. Require deployment approvals in acc and prd.
  7. Stop promotion if smoke tests fail.

2. Choose and validate a single-GPU environment

AI Runtime combines managed GPU infrastructure with a Python environment for deep learning. For workspaces with the compliance security profile enabled, an administrator must enable the AI Runtime and AI Runtime multi-node H100 previews. Check supported Geos, workspace eligibility and cross-Geo processing requirements before using confidential images.

Do not infer GPU processing location from workspace location. The Azure overview warns about constrained capacity and possible cross-region GPU use, including potential egress costs. Check availability by Geo and the actual processing path. For EU client data, permit EU processing only.

Compute pathSuitable starting pointRequired checks
AI Runtime with 1xA10A single-GPU workload that fits its 24 GB GPU memoryWorkspace eligibility, processing geography, capacity and dependencies
AI Runtime with 1xH100A single-GPU workload needing more memory; documented GPU memory is 80 GBMeasured memory demand and the same eligibility checks
Classic single-node Azure GPU computeA workload needing the classic runtime or cluster operating modelInstance availability, pinned GPU ML runtime, Photon disabled and package compatibility
AI Runtime with 8xH100A measured need for supported multi-GPU executionLauncher compatibility, applicable preview approval, data throughput and scaling benefit

Define classic Azure GPU compute through version-pinned NexOps Terraform modules, following the GPU compute documentation. Select a GPU instance and pin a GPU-enabled ML runtime. Disable Photon. Start with one training GPU rather than provisioning accelerators the process will not use.

Use private network paths for storage, workspace access and other data services. Disable public access where supported. Verify that the selected compute path meets these controls before loading client images. Keep environment resources and identities separate.

AI Runtime offers Standard and Databricks AI environments. The environment documentation states that Standard no longer pre-installs torch and torchvision from environment version 5 onwards; the AI environment includes PyTorch and other ML frameworks.

Record the chosen environment and resolved dependencies. Check the library inventory for the exact classic GPU ML runtime rather than assuming it includes a compatible PyTorch installation. Check the torchvision compatibility table when selecting a PyTorch–torchvision pair.

For scheduled AI Runtime jobs, install pinned dependencies programmatically through the documented notebook installation approach. Do not rely on packages added through the Environments panel. Interactive environment caching does not establish a reproducible scheduled job.

3. Establish explicit experiment tracking

MLflow tracking records experiment parameters, metrics and artefacts. It is distinct from model registration and deployment, so we make the experiment destination explicit before training.

python
import mlflow
 
mlflow.set_tracking_uri("databricks")
mlflow.set_registry_uri("databricks-uc")
experiment_name = "/Shared/logistics-label-detection"
 
# Reject missing infrastructure instead of creating default artefact storage.
experiment = mlflow.get_experiment_by_name(experiment_name)
if experiment is None:
    raise RuntimeError("Provision the approved experiment before training.")
 
mlflow.set_experiment(experiment_name)

Provision this team experiment through a NexOps-managed Terraform module with group permissions and a Unity Catalog volume artefact location. The code refuses to create it implicitly. The registry URI selects Unity Catalog for later registration; it does not register a checkpoint or approve deployment.

The Databricks experiment documentation supports explicit experiment selection and recommends Unity Catalog volumes for artefact storage. Use an approved experiment location and verify the execution identity can write there.

Choose one logging approach and make run ownership explicit. Consult the Ultralytics MLflow integration guide when configuring its integration for the selected package release, or add explicit MLflow logging around training. Do not depend on unverified callback settings or assume that a run remains open after training.

Do not assume that selecting an MLflow experiment makes the training library log to it. Check the resulting run in the workspace and confirm that parameters, validation metrics and checkpoint artefacts are present, with the dataset release and code revision attached.

4. Run a short training smoke test

Use a short smoke test to validate the selected Ultralytics release on the target Azure environment. The supplied computer-vision index confirms a YOLO11n example exists, but does not provide its runnable implementation. We therefore do not present an unvalidated training call as executable guidance.

  1. Stage reviewed pretrained weights and a release-specific dataset configuration in governed storage.
  2. Verify volume reads with the training identity.
  3. Confirm the selected release’s training arguments and output-location behaviour.
  4. Set a short training budget in the versioned configuration.
  5. Run the smoke test through the deployed development job.
  6. Check the resulting metrics, checkpoints and MLflow run.
  7. Persist required artefacts to governed storage before temporary compute storage disappears.

These checks establish loader, dependency and storage compatibility before a longer run. The smoke-test budget is not a quality target.

An epoch is one pass through the training dataset; learning rate, image size and batch size influence training behaviour. GPU time also includes validation, image decoding and augmentation, so profile the loader and accelerator before increasing hardware.

Do not combine an ordinary Ultralytics multi-device launcher with Databricks’ @distributed decorator without a validated integration. The Azure notebook distributed-training documentation marks the decorator as Public Preview and requires an 8xH100 accelerator. It uses all eight GPUs by default; num_accelerators selects fewer, while gpus is deprecated. This single-node notebook mechanism does not establish compatibility with an arbitrary training library’s launcher.

5. Evaluate and package the inference contract

Keep the test set out of hyperparameter selection. Inspect errors by class, capture device, site and lighting condition, and set acceptance criteria from downstream requirements rather than an arbitrary aggregate score.

For detection, precision measures how many reported detections are correct, while recall measures how many reference objects were found under the evaluation’s matching rules. Intersection over Union (IoU) measures box overlap; mean average precision (mAP) summarises precision–recall performance across the specified classes and matching thresholds.

A weights file is not a deployment contract. Define image input format, preprocessing, output schema, class mapping, confidence handling and malformed-input behaviour, then test those decisions in a clean environment.

An Ultralytics detector may need a custom MLflow pyfunc wrapper for preprocessing and output handling. Follow the custom model serving documentation, specifying application dependencies and checking that packaged predictions agree with notebook predictions.

6. Register, promote and choose an inference path

The custom model serving documentation states that model signatures are necessary for logging models to Unity Catalog. The registering identity also needs appropriate access to the destination; logging a raw .pt artefact does not make it a serving-ready MLflow model.

Registration provides versioning and governance, not approval to serve production traffic. Require evaluation evidence, dependency tests, access checks and a tested rollback path before promotion. Keep production approval separate from the training notebook.

We prefer batch inference when images arrive asynchronously and a queue is acceptable. Load an explicitly approved model version, process bounded image groups, and write identifiers, model version, boxes and confidence values to a governed results table.

Use online serving only when the consuming process needs request–response predictions. Deploy serving resources through bundles and CI/CD only after verifying private connectivity. Test authentication, payload validation, latency, reload behaviour and failure handling. Our inference cost and latency guide explains that operating trade-off.

Why It Matters

Databricks does not make an otherwise identical YOLO recipe intrinsically more accurate than Kaggle. Equivalent data, weights, code and settings should produce broadly comparable quality, although random initialisation and nondeterministic operations can cause run-to-run differences.

The platform advantage is control over the surrounding lifecycle. Dataset access, experiment history, retraining jobs and model promotion can belong to an organisational operating model rather than an individual notebook account.

Unity Catalog volumes govern non-tabular files such as images, annotations and manifests. Managed volumes suit Databricks-owned storage; external volumes add governance over existing object-storage locations. Neither option automatically makes a dataset immutable.

External access needs separate attention. The volume documentation explains that Unity Catalog does not govern direct cloud-storage access by external systems. Align cloud-native permissions or supported credential-vending arrangements with the intended access policy.

Our view: pay for the platform when you need the lifecycle, not simply because a notebook runs on it. GPU utilisation, failed experiments, annotation rework and serving capacity all belong in the cost discussion.

Use Case: Finding Shipping Labels in Confidential Logistics Images

Consider a hypothetical logistics organisation whose operational systems span on-premises infrastructure and Azure. Its back office receives parcel photographs containing shipping labels, addresses and barcodes, while peak-season volume increases the manual processing queue.

A personal notebook cannot provide the required confidentiality controls and reproducible release history. Changing annotations and shared weights files also obscure provenance. Operators need to know which model processed a shipment so the platform team can investigate errors.

In this hypothetical design, an ingestion service deposits only required images through private connectivity into storage governed by an external Unity Catalog volume. Development and test use masked or anonymised images; approved releases retain their purpose, owner and retention rules. An annotation process creates the dataset release and split manifest, and a GPU job records training in MLflow. An evaluated model passes registration and promotion gates before a batch job writes label regions to a governed results table.

A separate optical character recognition (OCR) process converts cropped label regions into text. Detecting a label is not the same as reading its address or decoding its barcode. Cases that fail detection or extraction go to a manual-review queue rather than silently disappearing from the process.

Measure missed labels, false detections, downstream extraction failures and manual-review demand. Also measure annotation effort, GPU utilisation, training duration and peak-period backlog. Those signals reveal whether the end-to-end process improved, not merely whether validation metrics increased.

Decision Guide

SituationTrade-offOur recommendation
Learning with public images or reproducing a tutorialA governed organisational platform adds administration without necessarily improving the experimentStart with Kaggle
Competition workData access and submissions must follow the competition rulesUse the permitted competition workflow
Confidential organisational imageryStorage, processing geography and access need explicit approvalUse an approved organisational environment
Repeatable retraining with operational ownershipNotebook-only execution makes provenance and promotion difficult to standardiseUse Databricks with versioned datasets and controlled jobs

Before relying on Kaggle compute, check its notebook documentation and GPU usage guidance. We do not treat any accelerator allocation, price or session quota as a permanent guarantee.

Pitfalls and Misconceptions

Resolve licences before committing to an implementation

Review the current Ultralytics licence terms with legal and procurement for the intended code, weights, fine-tuned model and deployment pattern. Do not assume that permission to run a tutorial also covers the intended internal or proprietary deployment.

If an alternative implementation is needed, evaluate options such as torchvision’s RetinaNet. Review the exact release’s code licence and separately check pretrained-weight and dataset conditions. The torchvision repository explicitly warns that dataset and pretrained-model permissions remain the user’s responsibility.

More GPUs do not fix bad data

Additional compute does not repair poor annotations, split leakage or inconsistent class definitions. It also does not fix a loader that cannot feed one GPU efficiently.

Profile the single-GPU baseline before scaling. Add distributed execution only when measured throughput or memory constraints justify its coordination and testing costs.

Serverless does not remove operating constraints

AI Runtime is Python-only without a local Spark runtime; Spark Connect is available for data loading. Do not move a notebook that depends on local PySpark execution unchanged, and treat Spark preparation and GPU training as separate tasks where appropriate.

Capacity and maximum execution durations still constrain workloads. Persist checkpoints, test recovery and verify the current limits in the Azure overview before scheduling long-running training.

Governance is not automatic reproducibility

Volumes control access, but mutable annotations can still invalidate a previous experiment. Protect released inputs, record their checksums and ensure the stored manifest matches the actual training data.

Likewise, registration does not guarantee a packaged model will load or use a serving GPU correctly. Test the actual inference package, not just the notebook that produced it.

Do not migrate a harmless learning exercise by default

Kaggle can remain the better tool for suitable public-data experiments. Move to an organisational platform when confidentiality, retraining ownership or production operation justify the additional cost and administration.

Key Takeaways

  1. Freeze reviewed inputs and check splits for leakage before training.
  2. Check AI Runtime eligibility, applicable preview approval, processing geography, private connectivity and dependencies.
  3. Profile one GPU before accepting the complexity of distributed execution.
  4. Verify experiment evidence and test the packaged inference contract before promotion.
  5. Resolve code, weight and dataset licensing before investing in a private integration.
  6. Match the platform to confidentiality, retraining ownership and operational needs.

Blijf op de hoogte

Ontvang het volgende artikel per e-mail

Volgende stap

Wil je hierover praten?

We praten graag over het vak. Heeft dit artikel je op een idee gebracht, of werk je aan iets vergelijkbaars? Dan maken we graag kennis.

Open voor projecten in Q4 2026