Skip to content
Skip to content
All posts
Language
ENDE

Home Deck, Away Deck: Training a Card Classifier in Java with JobRunr

with Ronald Dehuysser

Ronald Dehuysser, creator of JobRunr, and I trained an image classifier for 20 Java trading cards without leaving Java. Training ran as a JobRunr background job and recognition was a plain synchronous call. That split worked. The model only half did, because it had learned one deck in one room and was tested on another.

Published: November 12, 2026Reading time: 7 min read
Home Deck, Away Deck: Training a Card Classifier in Java with JobRunr

YouTube

Home Deck, Away Deck: Training a Card Classifier in Java with JobRunr

Load YouTube video

This video is embedded from YouTube and will only be loaded after your consent. When loading it, personal data may be transmitted to YouTube or Google and cookies may be set.

Open on YouTube

More details are available in the privacy policy.

Project Source

Working Repository

Explore prompts, instructions, and examples used in the live modernization workflow.

Open repository
Session Timeline

Training a model takes minutes. Recognizing a card takes one call. If your Java app treats both the same way, a user ends up waiting for a training run. This session was about splitting the two. We put the slow part into a JobRunr background job and kept the fast part synchronous, all in Java.

Ronald Dehuysser

Co-Speaker

Ronald Dehuysser

Creator at JobRunr

Ronald is a developer from Belgium. He started JobRunr in 2020, after working on a distributed Java invoicing project with more nano services than developers, no correlation IDs and invoices lost in a dead letter queue.

The deck

For this session I made 20 original trading cards about the Java world, in the style of Top Trumps. The deck runs from Duke and JobRunr to the Garbage Collector, NullPointerException and a Legacy Monolith. The goal was simple: hold a card up to the webcam, and the app names it.

Six of the 20 Java-Dex cards fanned out like a hand: Duke, Hibernate, Garbage Collector, Virtual Threads, NullPointerException and Legacy Monolith, each with a cartoon character, a job title and four stats
Six of the 20 Java-Dex cards fanned out like a hand: Duke, Hibernate, Garbage Collector, Virtual Threads, NullPointerException and Legacy Monolith, each with a cartoon character, a job title and four stats

Ronald took the training pictures himself. He held each card up to his webcam and pressed a button 20 to 30 times per card. Keep that detail in mind. It decides how the story ends.

Two speeds of work

The app has two jobs, and they run at very different speeds.

Training is slow. A prepare job splits the photos roughly 80/20 into training and validation sets and crops them to a card-shaped frame. A train job then runs the epochs and reports accuracy and loss at the end. On stream, training took about 24 minutes. On Ronald's machine it had taken about 10.

Recognition is fast. One webcam frame goes into the trained model and a card name comes out. That stays a plain synchronous call. No job, no queue, no waiting.

100%
JobRunr background jobs: slow, minutesLive synchronous call: no job, no waitingHome deckRonald's room, ~30 photos/cardPrepare jobsplit ~80/20, cropTrain jobResNet 18 + new headhead.jdthe trained headAway deckJohannes's room, liveWebcam frameone pictureClassifyResNet 18 + head.jdCard guessname + confidence≠different room,light and prints

JobRunr takes the slow part off the web request. The request returns right away, and the dashboard shows the job's logs and a progress bar. That bar is not magic, though.

The progress, you must maintain yourself, because JobRunr doesn't know how long it will last or what's even being done in there.

— Ronald Dehuysser, Creator of JobRunr

So the training code reports its own progress through the job context. In return you get a live view of a 24-minute job instead of a hanging browser tab.

Transfer learning without leaving Java

Nobody trained a neural network from scratch. DJL, the Deep Java Library, downloads ResNet 18, a pretrained image model with 18 layers. We only trained a small classification head on top of it for our 20 cards. That head lands in its own file, head.jd, next to the unchanged stock model.

Ronald picked ResNet 18 over ResNet 50 because it runs on lower-end hardware. DJL embeds the PyTorch C library through JNI behind a Java API. No Python, no extra service. Ronald mentioned Qwen vision as an alternative, but fine-tuning it would have meant leaving Java.

For a Java developer without an ML background, that is the useful part. You need a pretrained model, a few hundred photos and a job runner, not a new tech stack.

What JobRunr adds around the job

While the model trained, Ronald walked through what JobRunr does beyond running a method in the background.

  • Retries: a failed job is retried 10 times with exponential back-off by default. The @Job annotation sets the name, retries, labels and job filters.
  • Background servers: one property turns an instance into a background job server. Deploy the same jar twice, and a hidden instance does the heavy work while the web-facing one stays fast. On Black Friday, Ronald said, KEDA can scale up extra pods.
  • Shared databases: apps that share one database need separate table prefixes. Otherwise a server picks up jobs whose classes it doesn't have.
  • Load: stress tests reach about 5,000 jobs per second on Postgres, MariaDB and MongoDB. One company runs 8 billion jobs a year on it.

I asked how JobRunr compares to Temporal, which I had tried in an earlier session with Les Jackson. Temporal is language-agnostic. JobRunr lives inside your application. If the JVM dies, the jobs stop too, but Kubernetes restarts the pod and JobRunr picks up where it left off.

Here you don't need to ask your infrastructure team, hey, can I install Temporal? Because Temporal is again an extra piece of infrastructure that you need to manage and sometimes even hire people for.

— Ronald Dehuysser, Creator of JobRunr

The most surprising feature was carbon-aware scheduling. You give a job a time window, and JobRunr runs it when the grid's carbon intensity is lowest. Ronald said his team's analysis found carbon emissions and electricity price correlated in 99.9% of cases.

Home deck, away deck

Then came the webcam test. My first card was recognized. After that, most answers were wrong or jumped between cards, on my machine and on Ronald's. The Legacy Monolith scored 68% on my side and 100% on his.

The classifier's web page during the session: the XDEV card held up to the webcam inside a dashed frame, recognized as XDEV with 99.9% confidence, ahead of Tomcat at 0.1% and Lombok at 0.0%
The classifier's web page during the session: the XDEV card held up to the webcam inside a dashed frame, recognized as XDEV with 99.9% confidence, ahead of Tomcat at 0.1% and Lombok at 0.0%

When it hit, it hit with confidence: XDEV at 99.9%. The trouble was how rarely that happened.

The model had learned the home deck: Ronald's printed cards, in Ronald's room, under Ronald's light. It then played an away game with my prints, my room and my light. We listed possible causes on stream, none of them tested:

  • a different room and different lighting
  • my printed cards looking different from Ronald's
  • many cards sharing similar colors, such as the blue ones
  • only about 30 photos per card

The pipeline did its job. The training data was too narrow. Ronald's fix is to generate more varied images and retrain. We did not retrain on stream.

What else went wrong

The plan was to delete the finished code and rebuild it with an AI agent. That did not work. The first agent kept asking the same question and deleted one class. Sonnet then wrote the preparation method, but also moved and deleted files I hadn't asked about. At about the one-hour mark we switched to the finished code on the main branch. I would rather explain working code than watch an LLM write the rest.

Final thought

Slow work belongs in a job. Training ran for 24 minutes in a JobRunr background job, with progress and logs in the dashboard. Recognition stayed a synchronous call. DJL kept the whole thing in Java. That split held up on stream, even when the model didn't.

If you build something like this, start with a pretrained model and wrap the training in a job. Then test with a deck from a different room before you trust the accuracy number.

Comments

Load comments from GitHub optionally

The comment section is provided via Giscus and GitHub Discussions. It will only be loaded after your explicit consent. When loading it, personal data such as your IP address and technical metadata may be transmitted to GitHub, and cookies or similar technologies may be set.

Please confirm first before loading the comment section.

More details are available in the privacy policy.