Vibe Coding with ChatGPT on Ollama

Even though I had already declared Gemma the winner of the Photo Mosaic App “contest” in vibe coding, something interesting happened right after I finished my comparison. ChatGPT released a new Open Source Model for Ollama in the form of gpt-oss. This is a full reasoning model in 20 and 120 billion parameter models. That’s a huge deal! So, I owe it to myself, and anyone follow along, to test it out and so let’s see how will it performs.

gpt-oss:20b

Even if I could run it on my laptop hardware, the 120b parameter model wouldn’t be a fair comparison. The 20b model was the only other option and its double the parameters of the other models I ran to create the Photo Mosaic App. Deepseek was the 8b model (I actually tried the 14b model and it faired no better), Llama 3.2 was the 3b model, and Gemma was the 12b model. Remember, the requirement was that the models run on my laptop, after my experience with the Google AI Studio. To keep things fair I started with the same prompt I used with all the other models:

I like the strategy of using pyqt5. Write a python desktop app that references a directory of arbitrary image file types and creates a mosaic of tiled images that fills the screen. Make appropriate allowances for thread-based loading and memory management. Allow invocation via command line that specifies the interval between images loading, total images to display in the mosaic, and pixel dimensions of the display area.

As this is a full reasoning model, I started to get nervous as the model plowed through the challenge at hand. It took 55.1 seconds to produce the code below. At that mark, I was afraid it might be a repeat of the DeepSeek performance in nervous breakdown. But it was pretty cogent and, unlike DeepSeek, it didn’t get lost even as it considered some of the more daunting requirements in my request. The full text of the reasoning follows. If Gemma was my vibe coding “gal pal”, then GPT is my college software engineering professor. I mean, what GPT suggested is a really solid design. And, unlike Gemma, GPT got the tile layout (optimized within pixel parameters) mostly right from the start. It also implemented a sophisticated Class/Object model to manage the tiles within the app. So far, so good!

Full Reasoning Text from gpt-oss output – Click to Expand

We need to produce a full Python script using PyQt5, with ability to take command-line arguments: interval between images loading, total images to display in mosaic, and pixel dimensions of display area. The application should reference a directory of arbitrary image file types and create a mosaic of tiled images that fills the screen. Must consider thread-based loading and memory management.

We should produce code with appropriate structure: use argparse, use QThread or QRunnable with QThreadPool. Use QPixmap for images, load images from directory, maybe use QTimer to load images at interval. Use a grid layout or custom painting to create mosaic. Provide memory management: unload images no longer needed? But we display total images in mosaic; maybe after that, stop. Use a list of file paths. We need to handle different file types: use QImageReader to support many.

Also, we need to provide a command-line invocation: python app.py -d /path/to/images -i 500 -t 20 -w 1920 -h 1080 maybe.

Also need to set full screen or given width/height.

We’ll design:

  • Parse arguments: image_dir, interval_ms, total_images, width, height.
  • In main, create QApplication, MainWindow (subclass of QMainWindow or QWidget). In it, create a widget that draws mosaic: either use QLabel with pixmap scaled, or custom QWidget that overrides paintEvent to draw all images.
  • For loading images asynchronously: we can create a worker class subclass of QRunnable or QThread that loads an image from disk, scale it to tile size, and emit signal to main thread.
  • Use QTimer to trigger loading at interval. Keep track of loaded count.
  • For memory management: store images in a list up to total_images; beyond that maybe remove oldest.
  • For tile size: tile width = display width / columns; tile height = display height / rows; compute number of columns and rows based on number of images: e.g., we can decide to fill grid as close to square: rows = ceil(sqrt(total_images)), columns = ceil(total_images / rows). Or use width/height and tile dims accordingly.
  • Provide ability to set display area dimensions: if width/height not specified, use screen size.

We also need to ensure we handle scaling and painting efficiently.

We can use a QPixmap cache for each tile. The loaded images can be scaled and stored as QPixmap. They can be added to a list; then mosaic widget can paint them in grid.

We should handle thread-based loading: Use QThreadPool and QRunnable to load images. For each image, we load from file path, scale to tile size, then emit a signal.

We’ll need a custom signal: use pyqtSignal.

Let’s write code step by step:

Define Worker(QRunnable):

  • init: file_path, tile_size.
  • run: load image: QImageReader(file_path). Read image; convert to QImage; if invalid, skip. Scale to tile_size with smooth transformation. Convert to QPixmap. Emit signal via a QObject wrapper.

But QRunnable cannot emit signals directly; we need to pass a signal object.

We can define a QObject subclass with a signal: e.g., class ImageLoadedSignal(QObject): image_loaded = pyqtSignal(QPixmap).

But we can also use QRunnable with a callback function: after load, call a callback in main thread using QMetaObject.invokeMethod? Simpler: Use a QThread subclass.

Simpler approach: Use QThreadPool and a worker that uses signals via a QObject. Let’s define Worker(QObject, QRunnable). But multiple inheritance may cause issues. Alternative: Use QRunnable and use QImageReader, then use QMetaObject.invokeMethod to emit signal in main thread.

Better: Use QThreadPool and a function: use QRunnable to load image, then use QMetaObject.invokeMethod(self, “image_loaded”, Qt.QueuedConnection, …) But it’s simpler to create a custom QObject that holds the signal and pass that to the worker.

Simpler: Use QThread subclass for each image. But many threads is overhead. However, we can use a single QThread that sequentially loads images with delay. But we need interval.

Maybe simplest: Use QTimer in main thread to schedule image loads. For each interval, start a new QRunnable that loads image in background and returns pixmap via a callback. The callback will update UI using Qt’s signal/slot.

Thus:

class ImageLoader(QRunnable): def init(self, file_path, tile_size, callback): super().init() self.file_path = file_path self.tile_size = tile_size self.callback = callback

def run(self):
    reader = QImageReader(self.file_path)
    reader.setAutoTransform(True)
    image = reader.read()
    if image.isNull():
        return
    # Scale
    image = image.scaled(self.tile_size, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
    # Crop to tile_size
    w, h = image.width(), image.height()
    x = (w - self.tile_size.width()) // 2
    y = (h - self.tile_size.height()) // 2
    image = image.copy(x, y, self.tile_size.width(), self.tile_size.height())
    pixmap = QPixmap.fromImage(image)
    # Call callback in main thread
    # Use QMetaObject.invokeMethod
    QMetaObject.invokeMethod(self.callback, "addPixmap", Qt.QueuedConnection, Q_ARG(QPixmap, pixmap))

But using QMetaObject.invokeMethod requires a QObject method. So we can define a QObject subclass with method addPixmap(pixmap). That method will add to list.

Simpler: define a function callback that accepts pixmap; wrap it with Qt.QueuedConnection using QTimer.singleShot(0, lambda: callback(pixmap)). That will schedule it in main thread.

Yes: In run, after loading pixmap, do QTimer.singleShot(0, lambda: callback(pixmap)).

Now, the main window has method addPixmap that appends to pixmap list and updates display.

Memory: keep only pixmaps needed; if exceed total_images, we might drop older ones.

But we display mosaic of total_images; we may load them one by one until we hit total_images. So keep only loaded ones; we stop when count equals total_images.

We need to keep track of loaded images count.

The main window will maintain list of pixmaps.

For painting: Use a custom QWidget that overrides paintEvent. In paintEvent, iterate over pixmaps and draw them in grid. For tile geometry: we compute columns and rows as ceil(sqrt(total_images))? Or dynamic: we want to fill width x height. The tile size can be width/cols, height/rows. For best fill, we can compute rows = ceil(total_images / cols). But we can also compute based on width and height: For tile size 200×200, compute number of tiles that fit: cols = width // tile_size.width, rows = height // tile_size.height. But we have total_images. We need to adapt tile size accordingly: compute columns = ceil(sqrt(total_images)), rows = ceil(total_images / columns). Then tile_width = width / columns, tile_height = height / rows. This ensures all tiles fit and mosaic uses entire area.

Implement logic:

def compute_grid(self): cols = int(math.ceil(math.sqrt(self.total_images))) rows = int(math.ceil(self.total_images / cols)) self.cols = cols self.rows = rows self.tile_width = self.width() // cols self.tile_height = self.height() // rows

Also need to call compute_grid when resizing.

In paintEvent: For i, pixmap in enumerate(pixmaps): col = i % cols, row = i // cols. Then rect = QRect(coltile_width, rowtile_height, tile_width, tile_height). Draw pixmap scaled to rect size.

But pixmaps may be already scaled to tile size; but due to integer division, tile size may differ; we can scale in paint event.

Better: Pre-scale each pixmap to tile_size.

But we scaled in loader to tile_size; but we used tile_size param from computed tile dimensions. Good.

But due to rounding, we need to use same tile_size. Use tile_size = QSize(tile_width, tile_height). So loader should know the size.

Ok.

Let’s produce code skeleton:

  • import modules
  • parse args
  • find image files: use glob or os.walk for *.jpg *.png *.bmp *.gif etc. Also maybe support any file that QImageReader can handle; just try.
  • main: create QApplication, MainWindow. Pass args.
  • MainWindow: subclass QFrame or QWidget. Attributes: image_paths list, current_index, total_images, interval_ms, width, height, tile_width, tile_height, pixmaps list. Use QTimer to schedule loading: timer.timeout calls load_next_image.
  • load_next_image: if current_index < len(image_paths): file_path = image_paths[current_index]; current_index++. start ImageLoader(file_path, tile_size, self.addPixmap). Use QThreadPool.globalInstance().start(worker).
  • addPixmap(pixmap): Append to pixmaps. If len(pixmaps) > total_images: remove first. Call update() to repaint.
  • compute_grid on init and resize.
  • In paintEvent: iterate pixmaps and draw.
  • main: show full screen or size. Use setFixedSize(width, height) if specified; else full screen.
  • Use thread pool: from PyQt5.QtCore import QThreadPool
  • Use import PyQt5.QtWidgets, etc.
  • Provide main block.

Edge cases: if no images found, exit.

Also memory: keep only loaded pixmaps; but each pixmap memory size: tile size maybe 200×200, each ~200KB. With 100 images ~20MB. Fine.

Also allow for command-line options: -d/–dir, -i/–interval, -t/–total, -w/–width, -h/–height. Provide defaults: interval=1000ms, total=20, width=screen width, height=screen height.

Now produce code.

We’ll also add docstring and usage.

Let’s write code now.

GPT Photo Mosaic App

I was convinced this was going to be a 1-shot solution and GPT would be my new vibe coding professor friend. However, things didn’t really go that smoothly. In fact, like with Llama, the code didn’t run at all. The first error was a bit laughable – the “professor” had chosen to use a reserve overload value for the argparse functions to set up the command line invocation. It was funny just because of the professor-level sort of reasoning in the chat reasoning but GPT still managed to outwitted itself!

got-oss first fun is an overloaded function call error.

I felt like this was easy to figure out and fix (in less than a minute). All I had to do was change the argeparse constructor to upper-case H instead of lower-case h. Similarly, GPT-professor caught its error right away when I explained it, so ok, let’s fix it and give it another shot. Unfortunately, the result was still not so impressive. GPT interpreted the timer as the amount of time between AND before loading each tile. So, if I specified a 20-second interval (that shouuld have been) between mosaics then I got a blank screen for that interval. And, since I didn’t realize this at first, I thought there was an error in its display functions. Also, to be fair to Llama, I didn’t like the way GPT required so many “switches” in the invocation line (compared to Gemma). Below is what the user sees when the code runs: a nice blank screen.

gpt-oss creates a layout of blank screen and no tiles.

But as soon as the “interval” expired it turns out the “professor” had outwitted itself again. It failed to implement its own design well. The invokeMethod and callback throws an error when it is time to display images. I leave it to the reader to examine the full code (below) and determine if this is something you want to troubleshoot with the “professor”. In terms of design it is textbook-quality implementation. But you quickly get the sense this is like the same reason we don’t speak the Queen’s English – it just isn’t necessary unless you’re having tea with the Queen.

gpt-oss software fails to run when its time to display images.
Full Code of gpt Photo Mosaic App – Click to Expand
!/usr/bin/env python3
"""
image_mosaic.py – A lightweight PyQt5 desktop mosaic viewer

Usage

python image_mosaic.py [options]

Options

-d, --dir        Directory that contains the images (required)
-i, --interval   Milliseconds between successive image loads (default: 1000)
-t, --total      How many images to show in the mosaic (default: 20)
-w, --width      Width of the display area in pixels (default: full screen)
-h, --height     Height of the display area in pixels (default: full screen)
-v, --verbose    Print diagnostic messages
The program scans the supplied directory for any image files that Qt can read,
then loads them in a background thread, tiles them into a grid and paints the
mosaic. The GUI automatically scales the tiles so that the whole window is
filled.

Dependencies

  • Python 3.6+
  • PyQt5 5.15+ (install with pip install PyQt5)
import os
import sys
import math
import argparse
from pathlib import Path
from typing import List
from PyQt5.QtCore import (
Qt,
QTimer,
QSize,
QThreadPool,
QRunnable,
QMetaObject,
Q_ARG,
)
from PyQt5.QtGui import QPixmap, QImageReader
from PyQt5.QtWidgets import (
QApplication,
QWidget,
QMainWindow,
QVBoxLayout,
QLabel,
QSizePolicy,
QMessageBox,
QDesktopWidget,
)

—————————————————————————

Helper ———————————————————————

—————————————————————————

def find_images(root: Path) -> List[Path]:
"""Return a list of image files (any type supported by QImageReader)."""
# Basic file extensions – we could expand this if you want stricter filtering
extensions = {".jpg", ".jpeg", ".png", ".bmp", ".gif", ".tiff", ".webp"}
return sorted([p for p in root.rglob("*") if p.suffix.lower() in extensions])

—————————————————————————

Worker ———————————————————————

—————————————————————————

class ImageLoader(QRunnable):
"""
QRunnable that loads an image from disk, scales it to the requested tile size
and then hands the QPixmap back to the UI via a callback.
"""
def __init__(self, file_path: Path, tile_size: QSize, callback):
    super().__init__()
    self.file_path = file_path
    self.tile_size = tile_size
    self.callback = callback
def run(self):
    reader = QImageReader(str(self.file_path))
    reader.setAutoTransform(True)
    image = reader.read()
    if image.isNull():
        if _verbose:
            print(f"[WARN] Unable to load image: {self.file_path}")
        return
    # Scale *and* crop to a square of tile_size
    image = image.scaled(
        self.tile_size, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation
    )
    w, h = image.width(), image.height()
    x = (w - self.tile_size.width()) // 2
    y = (h - self.tile_size.height()) // 2
    image = image.copy(x, y, self.tile_size.width(), self.tile_size.height())
    pixmap = QPixmap.fromImage(image)
    # Deliver the pixmap back to the main thread
    QMetaObject.invokeMethod(
        self.callback, "addPixmap", Qt.QueuedConnection, Q_ARG(QPixmap, pixmap)
    )
class MosaicWidget(QWidget):
"""
The main widget that manages the mosaic grid, loads images asynchronously,
and paints the tiled mosaic.
"""
def __init__(self, image_paths: List[Path], total: int, interval_ms: int,
             display_size: QSize, parent=None):
    super().__init__(parent)
    self.image_paths = image_paths
    self.total = total
    self.interval_ms = interval_ms
    self.display_size = display_size
    # Layout
    self.setMinimumSize(1, 1)  # allow the window to be resized
    self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
    # State
    self.current_index = 0          # index into image_paths
    self.loaded_pixmaps: List[QPixmap] = []  # holds up to `total` pixmaps
    # Grid geometry
    self.cols = 1
    self.rows = 1
    self.tile_size = QSize(1, 1)
    self._compute_grid()
    # Thread pool
    self.thread_pool = QThreadPool.globalInstance()
    if _verbose:
        print(f"[INFO] Using {self.thread_pool.maxThreadCount()} threads")
    # Timer to schedule image loads
    self.timer = QTimer(self)
    self.timer.setInterval(self.interval_ms)
    self.timer.timeout.connect(self._load_next_image)
    self.timer.start()
    # A label for optional status (e.g. progress)
    self.status = QLabel(self)
    self.status.setStyleSheet("color: white; background: rgba(0,0,0,0.5);")
    self.status.setAlignment(Qt.AlignCenter)
    self.status.setVisible(False)
# ----------------------------------------------------------------------- #
# Qt Overrides ----------------------------------------------------------- #
# ----------------------------------------------------------------------- #
def resizeEvent(self, event):
    super().resizeEvent(event)
    self._compute_grid()
    self.update()
def paintEvent(self, event):
    super().paintEvent(event)
    if not self.loaded_pixmaps:
        return
    painter = QtGui.QPainter(self)
    for i, pixmap in enumerate(self.loaded_pixmaps):
        row = i // self.cols
        col = i % self.cols
        x = col * self.tile_size.width()
        y = row * self.tile_size.height()
        painter.drawPixmap(x, y, pixmap)
# ----------------------------------------------------------------------- #
# Public Slots ----------------------------------------------------------- #
# ----------------------------------------------------------------------- #
def addPixmap(self, pixmap: QPixmap):
    """
    Slot called by ImageLoader to add a new pixmap to the mosaic.
    """
    self.loaded_pixmaps.append(pixmap)
    # Keep only the most recent 'total' pixmaps
    if len(self.loaded_pixmaps) > self.total:
        self.loaded_pixmaps.pop(0)
    self.update()
# ----------------------------------------------------------------------- #
# Private helpers -------------------------------------------------------- #
# ----------------------------------------------------------------------- #
def _compute_grid(self):
    """
    Compute how many rows/cols and the tile size based on the desired
    total number of images and the widget's current size.
    """
    # Make the grid as square as possible
    self.cols = int(math.ceil(math.sqrt(self.total)))
    self.rows = int(math.ceil(self.total / self.cols))
    # Tile size that will fill the widget (integer division)
    width = self.width() // self.cols
    height = self.height() // self.rows
    self.tile_size = QSize(max(width, 1), max(height, 1))
    if _verbose:
        print(f"[DEBUG] Grid: {self.cols} cols x {self.rows} rows "
              f"-> tile {self.tile_size.width()}x{self.tile_size.height()}")
def _load_next_image(self):
    """
    Trigger loading of the next image, if any remain.
    """
    if self.current_index >= len(self.image_paths):
        # No more images – stop the timer
        self.timer.stop()
        if _verbose:
            print("[INFO] All images queued – stopping loader.")
        return
    # Start a worker that will load the image asynchronously
    path = self.image_paths[self.current_index]
    self.current_index += 1
    worker = ImageLoader(path, self.tile_size, self)
    self.thread_pool.start(worker)
    if _verbose:
        print(f"[INFO] Queued {path} ({self.current_index}/{len(self.image_paths)})")
class MainWindow(QMainWindow):
def init(self, args):
super().init()
self.args = args
    # Scan for images
    img_dir = Path(args.dir).expanduser()
    if not img_dir.is_dir():
        QMessageBox.critical(self, "Error", f"'{img_dir}' is not a directory")
        sys.exit(1)
    self.image_paths = find_images(img_dir)
    if not self.image_paths:
        QMessageBox.critical(self, "Error", f"No image files found in {img_dir}")
        sys.exit(1)
    # Limit to 'total' images requested
    self.total = min(args.total, len(self.image_paths))
    if _verbose:
        print(f"[INFO] Found {len(self.image_paths)} images, "
              f"using first {self.total} for the mosaic")
    # Determine display size
    if args.width and args.height:
        display_size = QSize(args.width, args.height)
    else:
        # Use full screen size
        desktop = QDesktopWidget()
        screen_rect = desktop.screenGeometry()
        display_size = QSize(screen_rect.width(), screen_rect.height())
    # Create the mosaic widget
    self.mosaic = MosaicWidget(
        self.image_paths,
        total=self.total,
        interval_ms=args.interval,
        display_size=display_size,
    )
    self.setCentralWidget(self.mosaic)
    # Window settings
    if args.width and args.height:
        self.resize(display_size)
    else:
        self.showFullScreen()
    self.setWindowTitle("Image Mosaic")
    # Optional: show a progress bar or status label
    # (Not implemented here but easy to add if desired)
_parser = argparse.ArgumentParser(description="Build a tiled image mosaic")
_parser.add_argument(
"-d", "--dir",
required=True,
help="Directory containing image files",
)
_parser.add_argument(
"-i", "--interval",
type=int,
default=1000,
help="Interval between image loads (ms)",
)
_parser.add_argument(
"-t", "--total",
type=int,
default=20,
help="Total number of images to display in the mosaic",
)
_parser.add_argument(
"-w", "--width",
type=int,
help="Width of the display area in pixels",
)
_parser.add_argument(
"-h", "--height",
type=int,
help="Height of the display area in pixels",
)
_parser.add_argument(
"-v", "--verbose",
action="store_true",
help="Enable verbose debugging output",
)
args = _parser.parse_args()
_verbose = args.verbose
if name == "main":
app = QApplication(sys.argv)
window = MainWindow(args)
window.show()
sys.exit(app.exec_())

GPT Summary

I am in awe of all these models. DeepSeek may have got things woefully wrong but its humanity is astounding. Llama is like that 1st year engineering student that realizes they really want to be a writer. Gemma is an old-school hacker and that appeals to me personally on a deep level. GPT-oss is like a college professor that hasn’t written code outside of academia for a long time. On a practical level, I think in the future I’ll likely start with Gemma and have the “Professor” check our work for us. In the meantime, I’ll be using Gemma’s code to display my photos on flatscreens via cheap Raspberry Pi SOCs.