File size: 5,995 Bytes
bb3611e
48b1aae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bb3611e
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!doctype html>
<!-- The LeanScene Space on Hugging Face: shot detection only, under its own header. This file is
     the page around the detection view; publish.sh fills in the rest from demo/index.html, so
     that what shows the detections is the same in both places and is kept in one place:
       demo.css    its stylesheet
       RESULTS     its results section (player, timeline, transition cards), put in below
       engine.js   its script, up to where shot search is loaded
     and adds the wordmark from logo/ as logo.svg and logo-dark.svg.
     See ../publish.sh. -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>LeanScene: shot detection</title>
<link rel="stylesheet" href="demo.css">
<style>
  main { padding-top:22px; }
  h1.logo img { display:block; height:36px; width:auto; margin-left:-4px; }  /* two thirds of the demo's size; demo.css picks the light or dark one */
  h1.logo span { top:-8px; }
  header p { margin:4px 0 0; max-width:72ch; }
  .links { display:flex; flex-wrap:wrap; gap:6px 18px; margin:10px 0 0; font-size:13px; }
  .links a { color:inherit; }
  #drop { margin-top:16px; }
  .examples { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; margin:10px 0 0; font-size:13px; }
  .examples small { font-size:12px; } .examples a { color:inherit; }
  #status:not(.err) { display:block; margin:10px 0 0; }  /* the demo shows this in a pill; here it is a line of text */
</style>
</head>
<body>
<main>
  <header>
    <h1 class="logo"><img class="l" src="logo.svg" alt="LeanScene"><img class="d" src="logo-dark.svg" alt="LeanScene"><span><em class="badge">Shot detection</em></span></h1>
    <p class="mute">Finds every cut, dissolve and fade in a video. The model is 1.6 MB and runs in this browser tab: your video is not uploaded.</p>
    <p class="links mute">
      <a href="https://huggingface.co/lucaspy/LeanScene" target="_blank" rel="noopener">Model card and benchmarks</a>
      <a href="https://github.com/lucasjacks0n/LeanScene" target="_blank" rel="noopener">Code on GitHub</a>
      <a href="https://lucasjackson.dev/leanscene/" target="_blank" rel="noopener">Full demo, with search by description</a>
    </p>
  </header>

  <label id="drop" class="busy">
    <input type="file" id="file" accept="video/mp4,video/quicktime,.mp4,.mov,.m4v" hidden>
    <strong>Drop a video here</strong>
    <span class="mute">or click to choose one (MP4 or MOV). It is processed in this tab and never uploaded.</span>
  </label>
  <p class="examples mute">Example
    <button class="plain" id="sample" disabled>Big Buck Bunny, 50 s</button>
    <small>© Blender Foundation, <a href="https://www.bigbuckbunny.org/" target="_blank" rel="noopener">bigbuckbunny.org</a>, <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener">CC BY 3.0</a></small>
  </p>
  <p id="status" class="mute">Loading model…</p>
  <p id="error" style="margin-top:10px" hidden></p>

  <section id="progress" hidden>
    <canvas id="live" width="100" height="100"></canvas>
    <div>
      <p id="ptext">Starting…</p>
      <progress id="pbar" max="1" value="0"></progress>
    </div>
  </section>

  <section id="results" hidden>
    <div id="summary"></div>
    <video id="player" controls muted playsinline></video>
    <div id="strip"></div>
    <div id="ovwrap"><canvas id="overview"></canvas><div id="ovbox"></div><div id="ovhead"></div></div>
    <div id="tlwrap"><canvas id="timeline"></canvas><div id="playhead"></div><div id="tip" hidden></div></div>
    <div class="legend">
      <span><i style="background:var(--cut)"></i>cut probability</span>
      <span><i style="background:var(--fade)"></i>fade / gradual probability</span>
      <span>▼ detected transition</span>
      <span>Click to jump; ← → step between transitions. Pinch or Ctrl/⌘ + scroll to zoom; drag or scroll sideways to move.</span>
      <span class="zoom"><button class="plain" id="tprev" aria-label="Previous transition" title="Previous transition (←)">◀</button><button class="plain" id="tnext" aria-label="Next transition" title="Next transition (→)">▶</button><span id="zoominfo"></span><button class="plain" id="zout" aria-label="Zoom out">−</button><button class="plain" id="zin" aria-label="Zoom in">+</button><button class="plain" id="zfit">Fit</button></span>
    </div>
    <div class="row"><h2 id="cardsTitle">Transitions</h2><button class="plain" id="download">Download JSON</button></div>
    <p class="mute" style="font-size:13px;margin:-4px 0 10px">Each card shows the last frame before the transition and the first frame after it. Click a card to play from the transition.</p>
    <div class="pager top" hidden><button class="plain pprev">← Previous</button><span class="pinfo"></span><button class="plain pnext">Next →</button></div>
    <div id="cards"></div>
    <div class="pager bottom" hidden><button class="plain pprev">← Previous</button><span class="pinfo"></span><button class="plain pnext">Next →</button></div>
  </section>
</main>

<script src="https://cdn.jsdelivr.net/npm/mp4box@0.5.2/dist/mp4box.all.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.1/dist/ort.webgpu.min.js"></script>
<script src="model.js"></script>
<script src="engine.js"></script>
<script>
// engine.js is the demo's own script: it reads the video, finds the transitions and draws the
// results. All this page adds is the example button, then it starts loading the model.
"use strict";
$("sample").onclick = async () => {
  try { const r = await fetch("sample.mp4"); if (!r.ok) throw new Error("HTTP " + r.status); run(new File([await r.blob()], "big-buck-bunny.mp4", { type: "video/mp4" })); }
  catch (e) { $("error").textContent = "Could not load the example: " + (e.message || e); $("error").hidden = false; }
};
setInterval(() => { $("sample").disabled = !featS || busy; }, 200);
loadModel();
</script>
</body>
</html>