← All models

image-to-image (dehazing) Β· vision Β· WASM Β· ~4 MB

MicroDehazeNet β€” clear the haze from a photo

Give this model a hazy or foggy photo β€” a washed-out landscape, a misty street, an aerial shot lost in atmosphere β€” and it recovers the clear scene: restored contrast, revived colour, distant detail pulled back out of the murk. MicroDehazeNet is a tiny (~1M-parameter) single-image dehazing network trained on the Haze4K benchmark. It's not a contrast slider β€” it estimates and removes the scene's haze the way physics laid it down. Runs entirely on your device via ONNX Runtime Web; the photo never leaves the tab.

At a glance

ModelVive-k-kumar/micro-dehaze-net β€” MicroDehazeNet (996K params, base_channels 24), trained on Haze4K
Taskimage-to-image (single-image dehazing) β€” run via raw ONNX Runtime Web (see note below)
Runtimeonnxruntime-web 1.21 (transformers.js has no dehazing class / no dehazing task)
Inputhazy_input [1, 3, H, W] float32 in 0–1 β€” the hazy image, plain RGB (no normalisation), H/W rounded to a multiple of 8
Outputdehazed_output [1, 3, H, W] float32 in ~0–1 β€” the haze-removed image, resized back to your photo's aspect
Quantizationfp32 ONNX (weights in an external-data sidecar) β€” runs on the plain WASM execution provider, no WebGPU needed
BackendWebAssembly (single-threaded on GitHub Pages) β€” a 512-px pass is under a second
Download~4 MB (0.2 MB graph + 3.8 MB weights), cached after first load (auto-inits on return)
LicenseMIT Β· trained on Haze4K
Web APIsWebAssembly, Web Workers, OffscreenCanvas, ImageBitmap β€” all Baseline widely available

Run it

Pick an outdoor photo and add a known haze so you can watch the network clear it β€” or drop your own genuinely hazy photo. Drag the divider to compare hazy vs dehazed.

β—€ hazy inputdehazed β–Ά
Drop / choose your own hazy photo (a real foggy or misty shot works best)

Everything runs on your device β€” the photo and every dehazed pixel never leave the tab. Gallery images are rights-cleared samples (see each caption for the source).

See inside

Where did the model actually do something? This is the haze-removed map: the per-pixel difference between the hazy input and the dehazed output, amplified. It glows in the regions the model cleared β€” usually the distant, low-transmission areas where the haze was thickest β€” and stays dark where little needed removing. It's a proxy for the scene's transmission map: how much atmosphere each pixel was seen through.

Dehaze a photo to see where the model cleared it.

Why it matters

Haze, fog and atmospheric murk wash out contrast, mute colour and hide distant structure. On-device dehazing recovers the clear scene privately, with no upload and no per-image cloud cost:

MicroDehazeNet estimates and removes plausible haze; it can't invent detail that dense fog erased completely. Heavy haze clears partially β€” it's a rescue, not X-ray vision.

Use cases

Basics

Haze a photo, then watch the network clear it β€” wipe between hazy and dehazed and see the contrast jump back.

Practical

Restore a real foggy landscape or drone shot so distance and colour come back, then download the cleared image.

Wild

Push it: crank the haze to a whiteout and find the point where dehazing starts to give up.

Multi-model

Dehaze β†’ detect: clear the haze, then run object detection on the result to find things the fog was hiding.

How the API works

transformers.js has no dehazing class and no dehazing task, so we run the ONNX graph directly with ONNX Runtime Web. In goes the hazy image, out comes the clear one:

import * as ort from "onnxruntime-web";

// the .onnx graph references its weights in an external-data sidecar (.onnx.data)
const session = await ort.InferenceSession.create(graphBytes, {
  executionProviders: ["wasm"],
  externalData: [{ path: "micro_dehaze_net.onnx.data", data: weightBytes }],
});

// hazy image β†’ [1,3,H,W] float32 in [0,1] (plain RGB, no normalisation)
const input = new ort.Tensor("float32", toNCHW(hazy, W, H), [1, 3, H, W]);
const { dehazed_output } = await session.run({ hazy_input: input });

// dehazed_output is [1,3,H,W] in [0,1] β†’ clamp to RGBA and resize back to the original aspect
const clear = tensorToImage(dehazed_output.data, W, H);

Inference and the whole output composite run in a Web Worker so the UI never blocks, and the ~4 MB model is fetched through Cache Storage, so a returning visit auto-initialises with no re-download.

References