Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: train vision datasets that have some rows without an image (#12991)
Nilay04013e900d00
diff --git a/studio/backend/tests/test_vlm_repo_relative_image_paths.py b/studio/backend/tests/test_vlm_repo_relative_image_paths.pyindex b1faba1be27..aeb694fa37d 100644--- a/studio/backend/tests/test_vlm_repo_relative_image_paths.py+++ b/studio/backend/tests/test_vlm_repo_relative_image_paths.py@@ -56,3 +56,15 @@ def test_simple_image_text_still_resolves_a_bare_filename(monkeypatch, tmp_path)assert fetched == ["images/a.png"]assert len(out) == 1+++def test_bare_filenames_resolve_when_the_first_row_has_no_image(monkeypatch, tmp_path):+ fetched = _fake_hub(monkeypatch, tmp_path, ["images/a.png"])+ ds = Dataset.from_dict({"image": [None, "a.png"], "text": ["no picture", "a cat"]})++ out = format_conversion.convert_to_vlm_format(+ ds, instruction = "Describe.", dataset_name = "org/ds"+ )++ assert fetched == ["images/a.png"]+ assert [sample["messages"][1]["content"][0]["text"] for sample in out] == ["a cat"]diff --git a/studio/backend/tests/test_vlm_text_only_rows.py b/studio/backend/tests/test_vlm_text_only_rows.pynew file mode 100644index 00000000000..412bf89592a--- /dev/null+++ b/studio/backend/tests/test_vlm_text_only_rows.py@@ -0,0 +1,54 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++from datasets import Dataset+from PIL import Image++from utils.datasets import format_conversion+++def test_rows_without_an_image_are_left_out_of_vision_training():+ ds = Dataset.from_dict(+ {+ "image": [None, Image.new("RGB", (4, 4)), None],+ "text": ["no picture", "a black square", "also no picture"],+ }+ )++ out = format_conversion.convert_to_vlm_format(ds, instruction = "Describe.")++ images = [+ part["image"]+ for sample in out+ for message in sample["messages"]+ for part in message["content"]+ if part.get("type") == "image"+ ]+ assert len(out) == 1+ assert out[0]["messages"][1]["content"][0]["text"] == "a black square"+ assert all(isinstance(image, Image.Image) for image in images)+++def test_rows_without_an_image_do_not_count_as_broken_urls(tmp_path):+ import threading+ from functools import partial+ from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer++ Image.new("RGB", (4, 4)).save(tmp_path / "a.png")+ server = ThreadingHTTPServer(+ ("127.0.0.1", 0), partial(SimpleHTTPRequestHandler, directory = str(tmp_path))+ )+ threading.Thread(target = server.serve_forever, daemon = True).start()+ url = f"http://127.0.0.1:{server.server_address[1]}/a.png"+ try:+ ds = Dataset.from_dict(+ {+ "image": [url, None, None, url, None],+ "text": ["first", "none", "none", "second", "none"],+ }+ )+ out = format_conversion.convert_to_vlm_format(ds, instruction = "Describe.")+ finally:+ server.shutdown()++ assert [sample["messages"][1]["content"][0]["text"] for sample in out] == ["first", "second"]diff --git a/studio/backend/utils/datasets/format_conversion.py b/studio/backend/utils/datasets/format_conversion.pyindex 51eb137d7ef..d4a5afa2381 100644--- a/studio/backend/utils/datasets/format_conversion.py+++ b/studio/backend/utils/datasets/format_conversion.py@@ -449,6 +449,8 @@ def convert_to_vlm_format(image_data = Image.open(local_path).convert("RGB")else:image_data = Image.open(image_data).convert("RGB")+ elif image_data is None:+ raise ValueError("Row has no image")text_data = sample[text_column]if isinstance(text_data, list) and len(text_data) > 0:@@ -476,10 +478,18 @@ def convert_to_vlm_format(return {"messages": messages}total = len(dataset)- first_image = next(iter(dataset))[image_column]+ first_image = next(+ (row[image_column] for row in dataset if row[image_column] is not None), None+ )has_urls = isinstance(first_image, str) and first_image.startswith(("http://", "https://"))- # Bare-filename detection: build a basename to repo_path lookup so filename-only images resolve via hf_hub_download during conversion.+ if has_urls:+ with_image = [i for i, url in enumerate(dataset[image_column]) if url is not None]+ if len(with_image) < total:+ logger.info(f"Skipping {total - len(with_image)}/{total} rows without an image")+ dataset = dataset.select(with_image)+ total = len(with_image)+_image_lookup = None_IMAGE_EXTS = (".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp", ".tiff")if (