Skip to content
AI Engineering••14 min read

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.

Naoufal Ahaytaf
Naoufal AhaytafFounder & Lead Data Platform Engineer, NexOps
MLflowPyTorchDatabricksUnity CatalogUltralyticsKaggle
Article

A YOLO notebook that works on Kaggle answers one question: can this training code produce a useful detector? Moving it onto an organisation’s 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 takes the notebook-to-platform transition seriously: 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 the better decision.

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 — not evidence that its precise dependencies and notebook steps transfer unchanged to Azure, or that the detector will perform well on your images.

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

Hands-On

1. Prepare a governed dataset release

Assume administrators have created a dataset volume such as cv_dev.inspection.images and an artefact volume such as cv_dev.inspection.model_artifacts. Give the training identity access to approved inputs and required output locations, and test that unrelated datasets remain inaccessible.

Split images into training, validation and held-out test sets before tuning. Keep near-identical photographs, neighbouring video frames and images of the same shipment in the same split — leakage can make validation results look better than operational performance.

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.

The dataset configuration follows the official Ultralytics YOLO detection format. The path field defines the dataset root; train, val and the optional test field accept image directories, lists of directories or text files listing image paths. The names mapping assigns class names to zero-indexed class IDs.

Each annotated image uses a corresponding YOLO label file containing one row per object: class_id x_center y_center width height. Coordinates must be normalised to the range 0–1. Images containing no objects do not require a label file. Before training, verify image–label pairing, class indices and bounding-box coordinates against the official Ultralytics detection dataset guide.

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
DevelopmentApproved sample data; engineers can experiment
TestFixed dataset fixture; automated loader and inference-contract tests
AcceptanceRepresentative approved data; operational evaluation and access tests
ProductionApproved releases; controlled training and promotion identities

Version the deployment machinery too. Our Databricks bundle guide covers configuration and CI/CD discipline — a successful interactive notebook should not become the production scheduling mechanism.

2. Choose and validate a single-GPU environment

AI Runtime combines managed GPU infrastructure with a Python environment for deep learning. A workspace administrator must enable the preview, and the team must 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 the linked availability-by-Geo documentation rather than treating the overview as a region-by-region availability list.

Compute pathSuitable starting pointRequired checks
AI Runtime with 1xA10A single-GPU workload that fits its 24 GB GPU memoryPreview approval, 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, ML runtime, Photon disabled and package compatibility
AI Runtime with 8xH100A measured need for supported multi-GPU executionLauncher compatibility, data throughput and scaling benefit

For classic Azure compute, follow the GPU compute documentation: select the Machine learning option, choose a GPU instance and disable Photon. Start with one training GPU rather than provisioning accelerators the process will not use.

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. Databricks Runtime ML includes PyTorch, but that does not establish compatibility with every Ultralytics release; do not blindly replace its installation, and check the torchvision compatibility table when selecting a PyTorch–torchvision pair.

For scheduled AI Runtime jobs, install dependencies programmatically with the documented notebook installation approach rather than relying on packages added through the Environments panel. Pin the tested versions — 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.

import mlflow

# Select workspace tracking and the Unity Catalog model registry explicitly.
mlflow.set_tracking_uri("databricks")
mlflow.set_registry_uri("databricks-uc")
mlflow.set_experiment("/Shared/logistics-label-detection")

The experiment path is an example team-owned workspace location. The registry URI selects Unity Catalog for subsequent model-registration operations; it does not register a checkpoint or approve a 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

The following existing training example assumes reviewed pretrained weights have been staged as pretrained.pt and a verified data.yaml exists in the dataset release. It also assumes the selected environment supports the volume reads and writable local output path.

from pathlib import Path
from uuid import uuid4

from ultralytics import YOLO

release = Path("/Volumes/cv_dev/inspection/images/releases/release_001")
weights = Path("/Volumes/cv_dev/inspection/model_artifacts/weights/pretrained.pt")
run_name = f"smoke_{uuid4().hex}"
output_dir = Path("/local_disk0/tmp/yolo_runs")

model = YOLO(str(weights))
results = model.train(
    data=str(release / "data.yaml"),
    epochs=5,       # Smoke-test budget, not a quality target.
    imgsz=640,      # Illustrative; evaluate for the target imagery.
    device=0,       # First visible GPU; verify the target environment.
    project=str(output_dir),
    name=run_name,
)
print(f"Training output: {output_dir / run_name}")

The short epoch budget and image size are illustrative settings, not benchmark results or recommended production values. A unique run name separates outputs; copy approved artefacts to governed storage before temporary compute storage disappears.

TODO (editor): Validate this existing Ultralytics call, dataset loader, local output directory and volume-access method on the selected Azure environment. The supplied computer-vision index confirms a YOLO11n example exists but does not include its runnable implementation.

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 that API as Beta and requires 8xH100 with gpus=8; it is a single-node notebook mechanism, not proof that an arbitrary training library’s launcher is compatible.

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. Promotion should require evaluation evidence, dependency tests, access checks and a tested rollback path, with the production approval boundary 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. Test authentication, payload validation, latency, reload behaviour and failure handling; training hardware does not establish the right serving hardware. 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 reads and writes made directly against cloud storage 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 tutorial workflow that downloads these images into a personal notebook and shares a weights file breaks down when images are confidential or annotations change. Operators also need to know which model processed a shipment, and the platform team must reproduce that decision when investigating an error.

In a governed design, an ingestion service deposits approved images into storage exposed through an external Unity Catalog volume. An annotation process produces a versioned dataset release and split manifest; a GPU job trains the detector and records its experiment. An evaluated model passes registration and promotion gates before a batch job writes detected 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. Start with reviewed pretrained weights and a frozen, leakage-resistant dataset release.
  2. Evaluate AI Runtime for eligible deep-learning workloads, but verify preview approval, processing geography, capacity and dependencies.
  3. Establish and profile a single-GPU baseline before introducing distributed training.
  4. Verify MLflow logging explicitly; tracking, packaging, registration and production approval are separate steps.
  5. Resolve code, weight and dataset licensing before investing in a private integration.
  6. Choose Kaggle for suitable learning workflows and Databricks when governed retraining and controlled operation justify it.
Keep reading
TagsMLflowPyTorchDatabricksUnity CatalogUltralyticsKaggle
Stay in the loop

GET THE NEXT ONE BY EMAIL

New articles plus a short monthly roundup of what changed in Databricks and Azure.

Double opt-in. Unsubscribe with one click in any email.

Next Step

WANT TO DISCUSS THIS?

We love talking shop. If this article sparked an idea or you're tackling a similar challenge, let's connect.

Currently accepting projects for Q4 2026
Book a Call