Preserving Memories: How I (Almost) Delegated My Holiday Photo Book to a Local AI
I built a local AI Agent to design a holiday photo book using LangGraph, PyTorch, Ollama, and Qwen 3.5. A deep dive into Evaluator-Optimizer loops, face-safe cropping, and local compute trade-offs.
As a family, we love to travel, and one of our traditions afterward is creating a printed photo book to preserve those memories. While we always love the final product, actually building the book is a lengthy process that eats up far too many late nights. With another holiday already behind us and a new backlog of photos waiting, I got curious: how much of this process could I actually delegate to AI?
The goal was simple: take 3,000 raw photos from our family trip across China and generate a print-ready photo book compatible with the CEWE/Pixum desktop software we normally use. To keep myself honest, I had the ultimate baseline sitting on my hard drive. Our nearly finished, handmade photo book from that exact China trip. I wanted to see if an AI pipeline could match, or ideally surpass, the quality and speed of our own manual work.
There was just one strict constraint: privacy. While I share plenty with LLMs in my day-to-day, I am not a fan of uploading thousands of personal family photos to a closed-loop LLM cloud provider API (Gemini, Claude, or OpenAI).
Instead, in the good spirit of "RAM Altman," I decided to put my own local RAM to work. I choose an open-weights model running on my own hardware, specifically Qwen 3.5 9B, a compact multimodal model served locally via Ollama on an M4 Mac Mini. Because my setup takes "brute-forcing" the solution off the table, I had to be surgical with my architecture, combining classical computer vision in PyTorch with an agentic workflow in LangGraph.
But I did not arrive at that immediately, it was an iterative process. To get from 3,000 raw images on an SD card to a finished book, I broke the journey down into five steps:
- Step 1: Image Preprocessing
- Step 2: The .mcfx Ingestion Smoke Test
- Step 3: Page Spread (and the v0.1 Disaster)
- Step 4: The Architecture: Agentic Evaluator-Optimizer Loop
- Step 5: The Final Verdict (Did it go to print?)
1. Image Preprocessing: The Two-Stage Local Funnel
As I did not want to throw cloud GPUs at 3,000 high-resolution images, I needed to build a funnel. Asking a local Vision LLM to inspect 3,000 raw camera files one by one would choke my local RAM and take days. Instead, I split curation into two distinct stages:
Stage 1: Classical Computer Vision (PyTorch + OpenCLIP)
Based on our previous family photo books, my rule of thumb is that a great album needs roughly 200 photos. For the heavy lifting of cutting 3,000 shots down to ~200, I bypassed LLMs entirely and used PyTorch and OpenCLIP embeddings accelerated on Apple Silicon (MPS). The script runs deterministic checks, such as Laplacian variance for sharpness/blurriness, exposure balance, and face presence, clusters near-duplicate burst shots, scores visual aesthetics, downscales the keepers into fast lightweight thumbnails (data/thumbnails/), and exports curated_photos.json. Yes, a frontier LLM could theoretically do this, but my local model is too slow, I don't trust hosted APIs with family photos, and PyTorch is purpose-built to crunch through thousands of images in minutes.
Stage 2: Semantic Enrichment (Qwen 3.5 Vision)
Once the dataset was trimmed to ~200 lightweight thumbnails, I brought in my local Qwen 3.5 Vision model to act as an editorial assistant, enriching each image's metadata with three critical attributes:
- Landmark & Subject Recognition: Identifies what is actually happening in the frame (e.g., Mutianyu Great Wall or street food in Chongqing).
- Visual Weight (1–5): Scores whether a photo commands a full-bleed hero slot or belongs in a supporting grid box. In a later stage, my Agents optimized this.
- Gaze Direction: Detects whether subjects are looking left, right, or center so the layout engine doesn't place a portrait looking off the outside edge of a page.
This two-tier approach gave me rich semantic reasoning without melting my local RAM or leaking private photos to the cloud. Later in the project, after noticing that early layout tests were slicing off people's foreheads, I also bolted facenet-pytorch (MTCNN) onto this pipeline to detect exact face bounding boxes and lock a safe focal_point into the JSON.
The resulting metadata for a single photo looks like this:

The "Human-in-the-Loop" Reality Check:
Skipping ahead to my first end-to-end test, this curation step revealed the exact reason why AI only almost replaced me. When I reviewed the 200 photos selected by Stage 1, every single image was technically sharp and well-exposed. However, several of our favorite memories from the trip were completely missing.
Sometimes an objectively "ugly," slightly blurry, or poorly lit photo carries the highest emotional value because of the moment it captures. An algorithm optimizes for pixel quality, not (yet) for emotions. I manually swapped our essential family highlights back into the final 200-photo set, and re-ran the metadata enrichment so the downstream agents had the true story of our trip.
2. The Ingestion Smoke Test
Before writing a single line of agentic code, I had to prove a fundamental engineering question: Can Python inject a photo into a CEWE/Pixum project file without corrupting it?
When you save a project in the CEWE/Pixum desktop software, it outputs a proprietary .mcfx file. Under the hood, an .mcfx file is actually an SQLite database acting as a container around a master XML layout tree (data.mcf) and internal binary image blobs (safecontainer:/ entries). Every double-page spread is mapped onto a strict 4100 x 2700 unit coordinate grid (410 x 270 mm), complete with 110-unit (11.0 mm) safe margins and cutout crop offsets.
To de-risk the pipeline early, I ran a quick smoke test:
- Create a Blank Canvas: I opened the Pixum desktop app, created a single empty spread, and saved it as a starter .mcfx template.
- Inspect the Schema: Using Python’s sqlite3 and lxml, I unpacked the database to see how the software registers an image binary and binds it to an <area> XML tag on the page.
- Inject One Test Photo: I wrote a minimal script (inspect_pixum_starter.py) to insert a single JPEG into the SQLite blob table, write the bounding box coordinates into the XML tree, and repackage the .mcfx container.
When I double-clicked the modified file and saw my test photo render cleanly inside the official Pixum desktop app on the first try, I knew it was game on.

3. The Page Spread: Why a Python Script is a Terrible Art Director
Once I could programmatically write .mcfx files, my first instinct was to automate the entire book with a standard, deterministic Python script (v0.1).
Before we proceed, let's zoom in a bit on the technicalities of a photo book page. In CEWE/Pixum, a double-page Layflat spread is a single continuous canvas measuring 4100 x 2700 units (41 x 27 cm), split by a center fold at X = 2050 (205.0 mm) and framed by a 110-unit bleed and safety margin. My v0.1 script simply looped through my photos chronologically, dropped them into a rigid four-box editorial grid, and calculated a blind 50% center crop (0.5, 0.5) whenever an image's aspect ratio didn't match the frame:

I instantly had a complete photo book containing all 200 images, and visually, it was a disaster:
- Aspect Ratio Collisions: Vertical portrait shots of skyscrapers in Shenzhen were crammed into wide horizontal boxes, while sweeping panoramas of the Great Wall were squeezed into tiny postage-stamp squares.
- The Guillotine Crop: Because a blind 50% center crop anchors strictly on the geometric middle of the file, placing a portrait photo into a landscape box sliced off the top 25% of the image, decapitating half of my family.
A deterministic script is a great assembly line, but it is a terrible Art Director. This is where my agentic workflow came in.
4. The Architecture: Agentic Evaluator-Optimizer Loop
Instead of asking a single model to spit out thousands of lines of raw XML in one shot, I designed a runtime LLM-as-a-Judge architecture following Anthropic’s Evaluator-Optimizer pattern. Using LangGraph, the pipeline pairs Deterministic Grounding (on the left) with a self-correcting Evaluator-Optimizer Loop (on the right):

The Left Side: Deterministic Grounding
Before the agents ever wake up, two static inputs lock in the boundaries:
- Image Preprocessing: The final, human-verified selection of 200 photos, complete with lightweight thumbnails, semantic tags from Qwen Vision, and face-safe focal coordinates from facenet-pytorch (MTCNN).
- Trip & Design Context: To give the agents more context, I created an itinerary.yaml file, providing timelines, destinations, transport, hotels, and daily activities. And because I hated the rigid layouts of v0.1, I wrote an extractor script to inspect our older, handmade Pixum photo books and pull out our favorite custom page spreads, background hex colors, and typography rules into benchmark_style.json.
The Right Side: The LangGraph Evaluator-Optimizer Loop
Once the state is initialized, the graph processes the book spread by spread through four specialized stages:
- Story Editor Agent (Narrative Planner): Powered by Qwen 3.5 (9B), it cross-references itinerary.yaml and your Style Bible against the enriched photos to sequence them into narrative chapters and cohesive story beats, setting the pacing and visual flow of the book before layout begins.
- Art Director Agent (Optimizer Node): Powered by local Qwen 3.5 using strict Pydantic structured outputs. It translates the editorial story onto physical spreads—inspecting photo orientations and visual weights, picking a matching layout, selecting background palettes, setting initial crop offsets, and writing a concise headline and caption.
- Spread Renderer (Tool): Here is the secret to making small local models succeed at graphic design: this deterministic Python tool (preview_renderer.py) takes the Art Director's JSON draft and physically draws a 1200 x 790 pixel JPEG mockup of the spread on disk.
- Proofing Editor Agent (Multimodal Critic / Evaluator): The JPEG mockup is Base64-encoded and handed to Qwen 3.5 Vision with a dedicated system prompt (multimodal_critic.md). Acting like a strict Creative Director, it visually inspects the rendered page: Are any heads clipped by the top edge? Is the headroom too tight? Does the spread feel balanced?
- If Rejected: The Critic outputs structured redline feedback (e.g., "Headroom is too tight on the left portrait; pull focal_shift_y down by -0.15"), routing the LangGraph state back to the Art Director for a revision.
- If Approved (Pass): (Or after 5 revision attempts), the spread receives sign-off and is locked into final_spreads.
- The .mcfx Compiler (Terminal Node): Once all spreads pass the Proofing Agent, a deterministic compiler (stage4_pixum_compiler.py) translates the approved LangGraph state into CEWE/Pixum’s exact SQLite binary blobs and <area> XML tags, outputting a print-ready china_ai_book.mcfx file that opens natively in the Pixum desktop app.
5. The Verdict
Watching the Evaluator-Optimizer loop run in real time was easily the highlight of the build. Opening the sequential JPEG mockups (spread_attempt_0.jpg through attempt_4) and watching the layout visibly self-correct (catching cramped framing on the first pass and pulling the crop anchor down on the next) proved that the agentic reflection pattern works.
At the same time, this is where I hit the hard ceiling of my local hardware. Running Qwen 3.5 (9B) locally on a 16GB M4 Mac Mini got the job done for €0.00, but every visual critique cycle felt noticeably slow, and a model inevitably misses subtle aesthetic nuances. Stepping up to a larger open-weights model (like Llama 4, Mistral Small 3, or DeepSeek) on a higher-RAM machine, or routing the Proofing Editor Agent to a frontier multimodal model from Gemini, Claude, or OpenAI would immediately yield sharper visual taste and faster iteration. For this project, however, trading away raw speed and frontier-level critique was a deliberate choice to keep every family photo 100% private on my own device.
So, did I send the AI version to the printer?
Between the emotional blind spots during initial image selection, where the AI filtered out imperfect photos that held huge sentimental value, and the aesthetic ceiling of running a quantized 9B model on constrained hardware, the gap was still visible. When I showed both versions to my family, the vote was unanimous: for our China trip, we went with the handmade photo book.
Still, the pipeline is built, the .mcfx compiler works, and local multimodal models are getting sharper every month. With a few tweaks, a bit more development time, and our next holiday photo book already waiting in the queue, I wouldn't bet against the AI winning that family vote next time.