Skip to content

Obico AI Failure Detection

BamDude has an optional integration with a self-hosted Obico ml_api — a machine-learning service that watches camera frames during a print and flags spaghetti / failures before they get expensive. The integration is off by default. One provider runs at a time — Obico, or the cloud OctoEverywhere: turning one on turns the other off. When enabled, it polls camera frames, hands them to an Obico ML endpoint, smooths the result over time, and on a sustained failure either notifies you, pauses the print, or pauses and powers the printer off via a smart plug.

Self-hosted only — no cloud, no obico.io

BamDude talks to your own Obico ml_api over HTTP on your local network. It never connects to obico.io, never registers a printer with Obico's web app, never opens a WebSocket, and never uploads frames anywhere outside your LAN. Frames live in a 30-second in-process cache; the only external recipient of a snapshot URL is the ML container that you control.

When to use it

Obico is most useful for unattended overnight runs and farm-wide automation. It catches:

  • Detachment / spaghetti during the first 20 layers
  • Mid-print blob-of-death from a failed retraction or layer shift
  • Bed clogging on multi-spool prints

It is not a substitute for first-layer monitoring or HMS error notifications — those catch different failure modes faster.

Self-host the Obico ML API

You only need the ml_api container from Obico's stack. The web app, Django site, and printer registration are not required — BamDude doesn't speak Obico's printer protocol, only the raw classification HTTP endpoint.

For installation, updates and troubleshooting, see Standalone Obico ML server. The guide includes a downloadable script that runs only ml_api, generates an API token and preserves it during updates.


Setup

  1. Self-host the Obico ML server using the linked guide above.
  2. Open Settings → Failure Detection and keep Provider on Obico.
  3. Tick Enable Obico failure detection.
  4. Fill in:

    Setting Notes
    ML API URL Base URL of the ML container, e.g. http://10.0.0.20:3333, without an endpoint path.
    ML API token The token generated by the installer (token command).
    BamDude address for the ML API (optional) The address the ML container fetches camera frames from — BamDude's LAN address or its Docker service name, e.g. http://10.0.0.10:8000 or http://bamdude:8000. Empty = the External URL is used. See the note below.
    Sensitivity low / medium / high. Scales the Low / High levels the smoothed score has to pass.
    Action on detected failure Notify only, Pause print or Pause and cut power (notify, pause, pause_and_off). See below.
    Poll interval Seconds between frame captures (5–120). Shorter = faster reaction, more bandwidth + more ML cost.
    Monitored Printers Per-printer toggle list. Leave all on, or restrict to specific printers (e.g. enable only on the unattended overnight printer). A printer you delete leaves this list with it.
  5. Save. The Obico loop starts immediately for any printer in RUNNING state. The ML API URL, the token and the BamDude address are saved with their own Save connection button, and only an administrator can change them.

The ML API needs an address to fetch frames from

The ML container fetches every frame from BamDude itself, at <address>/api/v1/obico/cached-frame/{nonce}. That address is BamDude address for the ML API when it is filled in, otherwise Settings → Network → External URL. One of the two has to be set, and it must resolve from inside the ML container's network — not from your browser.

Fill in BamDude address for the ML API when the External URL is a public name behind a reverse-proxy login, or simply cannot be reached from the ML container: give BamDude's LAN address, or its Docker service name when both containers share a Docker network. It must be a full http:// or https:// address without credentials or query parameters. Only frame fetching uses it — links in e-mails and notifications keep using the External URL.

With neither address set, monitored prints are not checked: the AI badge reads AI not checking and the status card says No address for the ML API to fetch snapshots from.

Sensitivity Low / Medium / High

Setting Effect
Low Higher confidence threshold; fewer false positives but slower to alert and may miss subtle early failures.
Medium Obico's original thresholds — recommended starting point.
High Lower threshold; alerts earlier, more false positives on retraction blobs / shadows / camera glare.

How detection works

The loop polls each enabled, currently-printing printer at the configured interval:

  1. Capture — BamDude grabs a frame from the printer's local camera (no Bambu Cloud involvement).
  2. Stash — the JPEG goes into an in-process cache under a 32-byte random nonce, with a 30-second TTL.
  3. Hand off — BamDude sends the Obico ML API a URL pointing back at /api/v1/obico/cached-frame/{nonce}. The Obico server fetches that URL and runs its classifier. (This is why the address matters — the BamDude address for the ML API, or the External URL when that field is empty, has to be reachable from the Obico host.)
  4. Scoring — the decision is Obico's own, the same arithmetic its server uses. A single frame never triggers anything.

    • Each frame's raw value is the sum of the confidences of everything the model flagged in it.
    • The raw values are smoothed with an exponentially-weighted mean (alpha = 2/13), which starts from zero at every print.
    • Each printer has a background: the long-term average of its frames (about 20 hours of printing at the default 10 s interval). It is learned per printer and carried from one print to the next. Whatever that camera always sees — plate texture, a label, the purge chute — ends up in the background.
    • The score is the smoothed value minus the background. So what the camera always sees does not build into a failure; only what is new in the picture counts.
    • Below the Low threshold the print is safe; above High it is failing. Between the two it is failing only when the score also stands clearly above the print's own recent average — a detection that appeared and stays. A score that creeps up slowly between Low and High is not a failure.
    • The first 30 frames of a print are always safe (~5 minutes at the default 10 s poll interval).

    The background is kept in memory: it starts over when BamDude restarts and is learned again from the prints that follow. 5. Two levels — detection reacts at two levels, each once per print:

    • Alert level — the score is failing at the Low / High thresholds (verdict warning). BamDude sends one notification for the print, whatever action is configured. If the failure is still suspected three hours after the print's last notification, a reminder is sent — and again every three hours while it lasts.
    • Pause level — the signal has kept growing to 1.75 × the High threshold (verdict failure); the status card shows the number as Pause level. Pause print and Pause and cut power act here, also once per print.

    So with a pausing action you get the notification first, and the pause follows only if the signal keeps growing. With Notify only nothing more happens after the notification.

    Action What happens
    notify At the alert level, fires the dedicated AI Failure Detection notification event — a separate, opt-in trigger (off by default) with its own template, split out of printer_error so you can page on AI alerts without also being paged for every HMS hardware code. The alert carries the printer, the job name, the provider, the confidence score, the action taken, and the camera frame the detector flagged. Subscribe to it independently: each provider has its own AI Failure Detection toggle, and Telegram adds a matching per-chat notify item.
    pause The same notification at the alert level; at the pause level, sends a pause MQTT command to the printer and notifies again, naming the pause.
    pause_and_off As pause, and at the pause level also turns off the bound smart plug. Use this for overnight unattended workflows where you'd rather kill power than waste filament.

    A print's detection state lasts from its first frame to its end — through a pause and through a reconnect. A print that detection paused is not paused again after you press Resume, and its notification is not repeated. The next print starts fresh, also when it is a reprint of the same file. Switching detection off, or taking a printer off the monitored list, forgets its print.

Why is the cached-frame URL whitelisted?

/api/v1/obico/cached-frame/{nonce} is one of the few endpoints that bypasses the always-on auth gate — the Obico ML server has no way to send a bearer token for a one-shot GET. The 32-byte nonce + 30-second TTL is the security surface; without the nonce, the route returns 404. The path is exempt only inside the auth_middleware whitelist.

This is also why the address the ML API fetches from needs to be reachable from the ML host. If you front BamDude with a reverse proxy, either make sure /api/v1/obico/cached-frame/ is not blocked by an extra auth layer in nginx, or set BamDude address for the ML API to BamDude's LAN address so the ML container bypasses the proxy.

Sensitivity tuning

Start on medium. If Obico screams "failure" at every retraction blob, drop to low. If it misses obvious detachments, raise to high. Smoothing means single-frame outliers won't trip the action — you need a sustained confidence above threshold. Sensitivity moves the Low / High levels (and the Pause level with them); it does not change the background, which each printer learns by itself.

The exact thresholds live in backend/app/services/obico_smoothing.py; they're conservative by default (designed not to false-trip on Obico's reference dataset).

Watching what Obico sees

The detection panel under Settings → Failure Detection is split into a Status card and a Recent detections strip:

Status card

  • Detection active flag (green / red) — green only while Obico is enabled with an ML URL. The background loop itself starts with BamDude and merely sleeps while the feature is off; the flag does not report that loop.
  • Low / High thresholds after sensitivity scaling (so you can sanity-check Low / Medium / High really did adjust the numbers), and the Pause level — 1.75 × High, the score at which a pausing action acts.
  • For each currently-printing monitored printer:
    • Live classification — safe / warning (alert level) / failure (pause level)
    • Score (the smoothed value minus the printer's background — the number that's compared against the thresholds; never shown below zero)
    • checked: N — frames checked so far this print (so you can see the warmup countdown). This counts checks, not saved frames; hover it for the reminder.

Recent signals — the last events held in memory, with date/time, printer, classification and score. Only a check where the ML model found something, or whose verdict was warning / failure, becomes an event; a check that found nothing does not, so the list can stay empty for a whole print while detection runs — the empty list says so, and it is not a verdict on the print. Restarting BamDude clears this list. A frame is available only when it was successfully saved; BamDude never substitutes a newer camera image.

Saved detection frames

Turn on Save detection frames to keep evidence locally. This separate switch is off by default. The Saved frames tab survives restarts, and View detection opens the exact original JPEG sent to ML, with optional boxes and each detection's confidence. Turning recording off keeps existing evidence and does not stop live detection or its actions; while it is off, the Saved frames tab says so. Old recent signals cannot recover their missing frames.

Not every checked frame is saved — only the same events that reach Recent signals. An empty Saved frames tab with recording on means no such event is kept — none happened within the retention limits below, or the history was cleared; it is not a verdict on the prints or on the storage.

  • Saved observations include warning/failure even when no boxes were returned, and safe when detections were returned. An ML/camera error is not a safe or failed print verdict.
  • The displayed score is a sum/smoothed value, not a probability; it can exceed 1. Box percentages are confidence for individual detections, not confirmation of physical defects.
  • Boxes are shown as the ML server returned them. Some upstream Obico backends calculate box height using frame width; BamDude cannot identify the backend from the response and does not guess a correction. The original JPEG and raw box tuples remain unchanged. The viewer ignores EXIF rotation, matching the encoded pixel grid ML decoded.
  • Frame source and live-buffer arrival are shown separately. Camera exposure time is unknown: a buffered image may predate the inference request, and arrival is not capture time. A recorded job name/context is not proof the frame belongs to that physical run.
  • Limits are 15 days, 1 GB and 10,000 events for the farm, whichever requires cleanup first. At capacity, safe events are removed first, then warnings, then the oldest failures. New safe events cannot evict warning/failure evidence. The panel shows the actual oldest saved frame; it does not promise a full 15 days.
  • Backups include exactly the ready originals referenced by their database snapshot, with hashes checked. Recording continues during backup. Physical deletion is deferred while backup copies protected files; if this fills the store, new frames (including failures) may be skipped. The warning concerns saved coverage, not whether live detection is running.
  • Clear saved history requires confirmation and settings:update; it removes evidence, not archives/jobs. Existing backups keep their copies. Deleting a printer removes its history too. API keys cannot change this setting or clear history. History metadata requires printers:read; frame/details also require camera:view, with the key owner's rights and printer allowlist still enforced.

Frames contain camera imagery and enter normal backups: grant access and retain backups accordingly. A missing, expired or unreadable original is reported as unavailable; viewing history never starts another capture or sends a printer command.

The AI badge on the printer cards

You do not have to be on this page to watch detection track a print. Each card on the Printers page carries an AI badge next to the other health badges — grey while nothing is being watched, then green / amber / red as a monitored print is classified. The tooltip carries the current score; clicking it comes back here for the full status and history.

A printer detection is not watching shows no badge at all, rather than one implying it is covered.

The badge never claims a print is watched when it is not. While a monitored print waits for its first result it reads AI starting (grey). When the latest check produced no result — the ML server refused the token, could not be reached, the camera gave no frame, or no address is set for the ML API to fetch frames from — it reads AI not checking (amber), and its tooltip names the reason for that printer (the reason is shown to users with settings access; others see that the print is not being checked). No score is quoted without a result. The Active prints list on this page shows the same, and Test saves the form first, so a green result describes the configuration detection actually runs with.

The badge needs no settings permission

It is readable by anyone who can see printers. It deliberately carries no configuration — the ML server address stays behind settings:read. Saved history has separate printer/camera permissions as described above.


Requirements & Gotchas

  • Bidirectional reachability. BamDude has to reach the ML API at http://<obico-host>:3333/p/, and the ML container has to reach BamDude at <address>/api/v1/obico/cached-frame/{nonce}. Put that address into BamDude address for the ML API: if they're on the same Docker network, use the BamDude container's service name; on separate hosts, use the LAN IP. localhost only works when both run directly on the same host — inside a container it means the container itself.
  • An address for the ML API is required. With BamDude address for the ML API empty and no Settings → Network → External URL, BamDude has nothing to hand to the ML API; monitored prints are not checked and the badge reads AI not checking. Either address is enough.
  • Public URL caveat under reverse-proxy auth. The cached-frame route bypasses BamDude's always-on auth gate (the ML container can't send a bearer for a one-shot GET), so make sure your nginx / Caddy / Traefik isn't slapping its own auth layer on /api/v1/obico/cached-frame/. The route's own security surface is the 32-byte random nonce + 30-second TTL — without the nonce it 404s.
  • Calibration prints are skipped. The detection loop only runs while the print is in RUNNING state, so the calibration / first-layer phase isn't classified — Bambu's own calibration screens cause too many shapes that aren't real failures yet.
  • A Filament Calibration test print takes no action. Neither detector notifies about or pauses a print the Filament Calibration wizard sent.
  • First 30 frames ignored. Even within RUNNING, the 30-frame warmup means the first ~5 minutes of every print are deliberately quiet — gives EWM time to stabilise before triggering anything.
  • Once per print, at each level. The notification goes out once per print and the pause happens once per print; later scores in the same print don't re-trigger either. This is intentional — you don't want five "pause" commands stepping on each other when the spaghetti monster is already obvious, and a print you resumed after a detection pause is not paused again. The state lasts through pauses and reconnects and is dropped when the print ends; the next print — also a reprint of the same file — starts fresh. The one thing that repeats is the reminder: a failure still suspected three hours after the last notification is told again. A reminder never pauses the printer.
  • The background lives in memory. Each printer's background and each print's state are not stored on disk. After BamDude restarts, the background is learned again and a print already running is treated as a new one.
  • One printer's camera does not hold up the rest. A printer whose camera cannot be read shows AI not checking with its own reason; the other monitored printers are checked as usual.
  • Camera must be reachable. The detection loop fetches frames from the printer's local camera the same way the main BamDude UI does. If the camera page in the UI doesn't show a stream, Obico won't get one either.
  • Disk / RAM. ~4 GB RAM on the Obico host. CPU scales with monitored printer count × poll frequency. A 5 s interval across 8 printers is roughly 1.6 frames/sec, fine on most hardware.

Troubleshooting

No address for the ML API to fetch snapshots from
Fill in BamDude address for the ML API under Settings → Failure Detection (and press Save connection), or set the External URL under Settings → Network. Either way it has to be a hostname or IP that's reachable from inside the Obico container. Test by curl-ing it from a shell inside the Obico container.
The ML API is healthy but every check fails to fetch the frame
The ML container cannot reach BamDude at the address it was given — typically the External URL is a public name behind a reverse-proxy login, or a name the container cannot resolve. Set BamDude address for the ML API to BamDude's LAN address, or to its Docker service name when both containers share a network.
Test button returns an error
The ML API isn't reachable from BamDude. Check docker compose ps ml_api and try curl http://<obico-host>:3333/hc/ from the BamDude host. If /hc/ works but Test doesn't, double-check the URL field uses the same scheme (http:// vs https://) and port.
Service is running but no detections appear
No entry does not prove the print is safe. Entries appear for non-safe verdicts or returned detections; saved frames also require recording to be enabled and space available. Check the Status card to confirm the print is being polled before tuning sensitivity.
False positives on normal prints
Drop sensitivity High → Medium → Low. Also check the camera angle — if the frame includes too much non-print background (filament spools, AMS, the operator's cat) the model has more chances to see "spaghetti" in random shapes. What the camera sees all the time is learned as the printer's background and stops counting, but the background starts over when BamDude restarts — the first prints after a restart have less of it to lean on.
I got the notification but the print was not paused
That is the two levels at work. The notification goes out at the alert level; Pause print and Pause and cut power wait for the stronger Pause level shown on the status card. If the signal stops growing, the print keeps running and you decide yourself.
A print was paused by detection — will it be paused again after Resume?
No. The pause happens once per print, and the print keeps its detection state through the pause. If the failure is real, stop the print yourself.
Missed obvious failures
Raise sensitivity. Remember the 30-frame warmup at the start — the first ~5 min are deliberately quiet. Verify the camera angle actually shows the build plate (not just the toolhead).
/api/v1/obico/cached-frame/ returns 401 / 403
Your reverse proxy is enforcing its own auth layer on top of BamDude. Carve out an exception for that path; BamDude itself whitelists it from the always-on gate.

License & Attribution

Obico's ML model and detection algorithms are licensed AGPL-3.0 — the same license as BamDude, so derivative-work obligations are aligned. BamDude does not vendor or link any Obico code; it only calls the ML API over HTTP. The container image lives in Obico's registry; pull it from the upstream obico-server repo, not from ghcr.io/kainpl/bamdude.

Fail-safe behaviour

If Obico's API is unreachable or returns a non-2xx response:

  • The error is logged at WARNING, not ERROR (no spammy stack traces).
  • The detection loop keeps going — a transient outage doesn't disable detection permanently.
  • No spurious "failure" action fires from a missing classification.

If obico_enabled is toggled off mid-print, the loop stops on the next iteration; the print continues uninterrupted. What detection knew about the running prints is forgotten, so switching it back on starts each of them fresh.