Vibe Coding a Photo App with Gemma and Llama

This is the third post in a series on Vibe Coding with LLMs. The first post was about how DeepSeek had a nervous breakdown when confronted with this coding challenge. The second post was about Gemini and the Google AI Studio’s performance on the same problem and why that was problematic. Now let’s turn to Llama and Gemma to see how they performed on the same challenge. As a quick refresher, my goal was to built a Photo Mosaic App that displayed images. The motivating idea was to have something easily deployed on a variety of low-end hardware factors from my older platforms like my Thinkpad T460, or a cross-section of Raspberry Pi SOCs like the Zero W, the 3B/+, or the 3A+. So, basic requirements are low-latency, low-memory, system-only hardware, and (linux) python-based.

The Prompt

To be fair, I supplied all the models the same prompt. I had previously worked with Gemini and the Google AI Studio so I had a good idea of what I didn’t want (no offense, Gemini). After originally consulting with DeepSeek I had already confirmed my approach to use Python and PyQT5. After that, I just gave some general requirements and waited to see what happened. How well would models respond without sample code to guide them? In other words, it is one thing for a model to extend or expound on existing code (as a guide). Even a search engine would find web pages or GitHub projects with similar code. It is quite another thing, as many of us humans know, to stare down a blank page! Below is the full prompt for better or worse (ie, some prompt engineers may cringe).

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.

Llama 3.2:3b

Llama’s python code output is below. It’s a good start at a code outline but right away I didn’t really like interacting with Llama as much as the other models. It seemed “terse” in its output and after seeing DeepSeek’s reasoning abilities, it left me cold. Since that isn’t really technical analysis, let’s look at the output. The biggest issue is that the code didn’t run at all. It appears Llama neglected to implement its own “attribute” on line 63 and “self” (the class) has no “image_loaded” function defined. The invocation variables did follow my instructions but they were a bit more complex than I would have liked (as we’ll see when we compare with Gemma). Requiring two variables for screen resolution strikes me as overly strict and specifying intervals in milliseconds seems to miss the point of the display. Llama did do a good job of validating variable input but there was no error catching. Similarly, it did not check for file suffixes to even make sure they were actually photo files.

python app.py --dir_path=/path/to/images/ --interval=500 --total_images=1000 --pixel_width=25 --pixel_height=25
Full Llama Photo Mosaic Code – Expand to Review
import os
import sys
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtGui import QPixmap, QImage, QImageWriter
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
class MosaicThread(QThread):
"""
A thread that loads images from a directory and generates the mosaic.
"""
image_loaded = pyqtSignal(int) # Signal emitted when an image is loaded
def __init__(self, dir_path, total_images, pixel_width, pixel_height):
    super().__init__()
    self.dir_path = dir_path
    self.total_images = total_images
    self.pixel_width = pixel_width
    self.pixel_height = pixel_height
    self.current_image_index = 0
def run(self):
    # Load images from directory and generate the mosaic
    image_paths = [os.path.join(dir_path, file) for file in os.listdir(dir_path)]
    if len(image_paths) < self.total_images:
        raise Exception("Not enough files to create mosaic")
    # Create a QPixmap for each image and resize it to pixel dimensions
    images = []
    for i, path in enumerate(image_paths):
        img = QPixmap(path)
        resized_img = img.scaled(self.pixel_width, self.pixel_height, Qt.KeepAspectRatio)
        images.append(resized_img)
    # Tiling the images
    mosaic_width = len(images[0].width())
    mosaic_height = int(len(images) ** 0.5)
    if (mosaic_width * images[0].height() // pixel_height) % 1 != 0:
        mosaic_height += 1
    # Create a QPixmap for the mosaic
    self.mosaic_pixmap = QPixmap(mosaic_width, mosaic_height * pixel_height)
    for i, img in enumerate(images):
        x = (i % mosaic_width) * pixel_width
        y = int(i // mosaic_width) * pixel_height
        self.mosaic_pixmap.copy(x, y, pixel_width, pixel_height).copy(img.rect(), Qt.QRect())
    # Emit the signal when all images are loaded
    if len(images) == self.total_images:
        self.image_loaded.emit()
class MosaicApp(QWidget):
"""
A PyQt5 application that generates a mosaic of tiled images.
"""
def init(self, dir_path, interval, pixel_width, pixel_height):
super().init()
    # Create the GUI
    self.setGeometry(100, 100, 800, 600)
    layout = QVBoxLayout()
    self.setLayout(layout)
    self.mosaic_label = QLabel()
    self.image_loaded.connect(self.display_mosaic)
    threading.Thread(target=self.load_images).start()  # Start loading images in a separate thread
def load_images(self):
    """
    Load images from the specified directory and generate the mosaic.
    """
    dir_path = os.path.abspath(dir_path)
    interval = int(interval)
    pixel_width = int(pixel_width)
    pixel_height = int(pixel_height)
    # Create a MosaicThread instance
    thread = MosaicThread(dir_path, 1000 * interval, pixel_width, pixel_height)  # 1000 images per second
    def update_mosaic():
        if thread.isRunning():
            while thread.current_image_index < len(thread.images):
                thread.image_loaded.emit()
                threading.Timer(interval / 1000.0).start()  # Sleep for the specified interval
                thread.current_image_index += 1
    threading.Thread(target=update_mosaic).start()
def display_mosaic(self, image_id):
    """
    Display the mosaic on the GUI.
    """
    if self.mosaic_pixmap is not None:
        pixmap = QPixmap.fromImage(QImage(self.mosaic_pixmap.toImage()).rgbSwapped())
        self.mosaic_label.setPixmap(pixmap)
if name == "main":
app = QApplication(sys.argv)
# Parse command line arguments
import argparse
parser = argparse.ArgumentParser(description='Generate a mosaic of tiled images')
parser.add_argument('--dir_path', type=str, default='./images', help='Directory containing the images')
parser.add_argument('--interval', type=int, default=1000, help='Interval between image loads (ms)')
parser.add_argument('--total_images', type=int, default=10, help='Total number of images to display in the mosaic')
parser.add_argument('--pixel_width', type=int, default=50, help='Width of each pixel in the mosaic')
parser.add_argument('--pixel_height', type=int, default=50, help='Height of each pixel in the mosaic')
args = parser.parse_args()
# Create and show the GUI
mosaic_app = MosaicApp(args.dir_path, args.interval, args.pixel_width, args.pixel_height)
mosaic_app.show()
sys.exit(app.exec_())

Llama Summary

This might not be a fair test of Llama but I wasn’t impressed. The code was mediocre even for an outline and it really didn’t solve any of the component pieces I asked about. Worse, it didn’t run at all. Even if the code had run it would have run into issues with file types. I chose Llama 3.2 assuming it was the newest model. Even though 3.1 has a newer release by a couple of months, I didn’t feel like it was worth trying. In either case, the Llama models do not even claim to be good at coding activities. That seems a fair assessment.

Gemma 3:12b

I was excited about Gemma because I knew it was a derivative of Gemini. I chose 12b because it was closest to the size of the DeepSeek I tested without being too far beyond (the parameters) of Llama I tested. I used the same prompt as detailed above for Llama (which is also the same as I used for DeepSeek). I was impressed right away as Gemma seemed to anticipate important “features” I wanted but didn’t specify. Gemma correctly anticipated we would need do error catching, memory management, file type checking, and some basic pixel size and photo orientation. It also had the best interpretation of invocation parameters (below) and this was a pleasing turn of events.

python mosaic_app.py /path/to/your/image/directory -i 0.5 -n 50 -s 600,400

Gemma also produced code that actually ran! It did obey the screen size and the interval and correctly switched displayed and loaded images. Unfortunately, it did not create a mosaic and many of the images that load into the “tiles” did not display. One major problem is that the code conflates the screen resolution with the tile sizes. The logic of arranging optimized tiles within the specified pixel resolution is something Gemma really struggled to get right (albeit while consistently producing runnable code).

Testing the First Iteration of Gemma generated photo mosaic code.
Full Gemma Photo Mosaic Code – Expand to Review
import sys
import os
import threading
import time
import argparse
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout, QHBoxLayout
from PyQt5.QtGui import QPixmap, QImage
from PyQt5.QtCore import Qt, QSize, QTimer
class MosaicApp(QWidget):
def init(self, image_dir, interval, num_images, tile_size):
super().init()
    self.image_dir = image_dir
    self.interval = interval
    self.num_images = num_images
    self.tile_size = tile_size
    self.image_files = []
    self.displayed_images = []
    self.current_index = 0
    self.stop_flag = False  # Used for graceful shutdown
    self.init_ui()
    self.load_images()
    self.start_mosaic_display()
def init_ui(self):
    self.setWindowTitle("PyQt5 Mosaic App")
    self.label = QLabel()
    self.label.setAlignment(Qt.AlignCenter)
    self.label.setFixedSize(self.tile_size[0], self.tile_size[1]) # Match intended dimensions
    layout = QVBoxLayout()
    layout.addWidget(self.label)
    self.setLayout(layout)
def load_images(self):
    """Loads image files from the directory, filtering by extension."""
    allowed_extensions = ['.jpg', '.jpeg', '.png', '.bmp', '.gif']
    for filename in os.listdir(self.image_dir):
        if any(filename.lower().endswith(ext) for ext in allowed_extensions):
            self.image_files.append(os.path.join(self.image_dir, filename))
    if not self.image_files:
        print("No valid image files found in the directory.")
        self.stop_flag = True
        return
    # Limit the number of images to display
    self.image_files = self.image_files[:self.num_images]
    print(f"Loaded {len(self.image_files)} images.")
def display_image(self):
    """Displays a single image at a time."""
    if self.stop_flag:
        return
    try:
        image_path = self.image_files[self.current_index]
        pixmap = QPixmap(image_path)
        # Resize the image to the desired tile size
        resized_pixmap = pixmap.scaled(self.tile_size[0], self.tile_size[1], Qt.AspectRatioMode.KeepAspectRatio)
        self.label.setPixmap(resized_pixmap)
        self.displayed_images.append(image_path)
        self.current_index = (self.current_index + 1) % len(self.image_files)
    except Exception as e:
        print(f"Error displaying image: {e}")
        self.stop_flag = True  # Stop if there's an error
def start_mosaic_display(self):
    """Starts a timer to periodically display new images."""
    if self.stop_flag:
        return
    self.timer = QTimer(self)
    self.timer.timeout.connect(self.display_image)
    self.timer.start(self.interval * 1000)  # Interval in milliseconds
def stop(self):
    """Stops the timer and cleans up."""
    self.stop_flag = True
    self.timer.stop()
    QApplication.instance().quit()
def main():
parser = argparse.ArgumentParser(description="PyQt5 Mosaic App")
parser.add_argument("image_dir", help="Directory containing image files")
parser.add_argument("-i", "--interval", type=float, default=1.0, help="Interval between image changes (seconds)")
parser.add_argument("-n", "--num_images", type=int, default=100, help="Number of images to display in the mosaic")
parser.add_argument("-s", "--size", type=str, default="500,500", help="Pixel dimensions of the display area (e.g., '500,500')")
args = parser.parse_args()
try:
    width, height = map(int, args.size.split(','))
    tile_size = (width, height)
except ValueError:
    print("Invalid size format. Using default size (500, 500).")
    tile_size = (500, 500)
app = QApplication(sys.argv)
mosaic_app = MosaicApp(args.image_dir, args.interval, args.num_images, tile_size)
mosaic_app.show()
try:
    sys.exit(app.exec_())
except KeyboardInterrupt:
    print("Exiting...")
    mosaic_app.stop()
if name == 'main':
main()

Gemma Summary

I ended up continuing to work with Gemma. I found her (I feel like it’s a “she”) to be amiable and quite responsive. Gemma eventually solved the problem(s) and created the app successfully. Most of my back-and-forth with her was in the form of pointing out errors in her code. Running the code, looking for exceptions, having her generate “print” statements and refining try…catch blocks. Basically all the things I would have done to debug my own code! Even though Gemma is not a Reasoning Model her answers were well-thought, structured, and well-explained. I can truly say I did actually “vibe” with Gemma and I started to understand how that is a real coding advantage.

Gemma Wins! She created the Photo Mosaic App successfully.

In the end, I am not 100% certain I saved time. The amount of time I spent vibing might have been the amount of time I would have spent coding. But I absolutely did save effort. I just ran, checked, reported back to Gemma, and repeated. And, when it is my weekend and I have 100 little projects whispering in my ear, that reduced effort matters!