Spaces:
Running

File size: 3,524 Bytes
24f501d
10709fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24f501d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>PolypShift · live polyp segmentation demo</title>
  <meta name="description" content="Live in-browser demo: a ResNet34 U-Net outlines colon polyps. Runs on your device with ONNX Runtime Web.">
  <meta name="color-scheme" content="light dark">
  <link rel="icon" href="assets/favicon.svg" type="image/svg+xml">
  <link rel="stylesheet" href="styles.css">
  <link rel="stylesheet" href="demo.css">
  <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.31.1/dist/ort.wasm.min.js" integrity="sha384-tNxIwEqSlcdvKtUte98AsccPbDKM958LBXB/+3BLS42TTihXHKTWgdqPqXI/lot8" crossorigin="anonymous"></script>
  <script src="common.js"></script>
</head>
<body>
  <main class="wrap">
    <div data-banner></div>
    <div class="demo-head">
      <span class="eyebrow">L2 · Live demo · Colonoscopy</span>
      <h1>PolypShift: outline a polyp, on your device</h1>
      <p class="lede">A ResNet34 U-Net trained on Kvasir-SEG marks every pixel it thinks is polyp. It scores Dice 0.894 on held-out Kvasir images but 0.649 to 0.754 on other hospitals' equipment. Try an example or your own image and move the threshold.</p>
    </div>

    <div class="demo-grid">
      <section class="panel" aria-label="Controls and results">
        <h2>Input</h2>
        <div class="field">
          <span class="lbl">Example (Wikimedia Commons, no expert masks)</span>
          <div class="btn-row" id="examples"></div>
        </div>
        <div class="field">
          <label for="file">…or your own colonoscopy image</label>
          <input type="file" id="file" accept="image/png,image/jpeg,image/webp">
        </div>
        <div class="field">
          <label for="thr">Threshold: <span id="thr-val" class="mono">0.40</span> <span class="cap">(0.40 chosen on validation)</span></label>
          <input type="range" id="thr" min="0.05" max="0.95" step="0.05" value="0.4">
        </div>
        <div class="field">
          <label><input type="checkbox" id="tta" checked> Flip test-time augmentation (4 passes, as evaluated)</label>
        </div>
        <div id="load"><div class="status">Loading…</div><div class="bar-track"><div class="bar-fill"></div></div></div>

        <h2>Model output</h2>
        <div class="verdict" id="verdict">Waiting for the model…</div>
        <p class="note">The area is a share of the picture, not a physical size: it changes with camera distance. An empty mask does not rule out a polyp. Every training image contained a polyp, so the model can also mark normal tissue.</p>
        <p class="note">Model: ONNX export of the shipped U-Net with its weights stored in 16-bit (49 MB, computed in 32-bit). Downloaded once, then cached by your browser.</p>
      </section>

      <section class="panel" aria-label="Segmentation">
        <h2>Predicted polyp (blue)</h2>
        <div class="pair">
          <figure><div class="canvas-wrap"><canvas id="out" width="512" height="512" role="img" aria-label="Image with predicted polyp mask"></canvas></div><figcaption>Mask overlay at the chosen threshold</figcaption></figure>
          <figure><div class="canvas-wrap"><canvas id="heat" width="256" height="256" role="img" aria-label="Probability map"></canvas></div><figcaption>Raw probability map (256 × 256 model input)</figcaption></figure>
        </div>
      </section>
    </div>
  </main>
  <script src="app.js"></script>
</body>
</html>