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
# 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(monkeypatch):
import io
from core.inference import tools
png = io.BytesIO()
Image.new("RGB", (4, 4)).save(png, format = "PNG")
# Row URLs go through the SSRF-guarded fetch, which refuses loopback, so stub it.
monkeypatch.setattr(
tools, "_fetch_url_raw", lambda url, **kwargs: (None, png.getvalue(), "image/png")
)
url = "https://example.com/a.png"
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.")
assert [sample["messages"][1]["content"][0]["text"] for sample in out] == ["first", "second"]