File size: 12,445 Bytes
818903f
97efb9d
6b1080e
 
 
e1b9ef5
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
6b1080e
3741f37
 
 
 
 
 
 
 
 
 
97efb9d
 
6b1080e
e1b9ef5
6b1080e
97efb9d
 
 
 
 
6b1080e
97efb9d
e1b9ef5
9959147
 
 
3f53d5c
9959147
 
e1b9ef5
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
6b1080e
 
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
 
6b1080e
e1b9ef5
 
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
6b1080e
e1b9ef5
6b1080e
 
e1b9ef5
 
6b1080e
e1b9ef5
6b1080e
e1b9ef5
 
 
 
 
 
330fbdb
e1b9ef5
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
 
 
e1b9ef5
 
6b1080e
e1b9ef5
 
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
6b1080e
 
e1b9ef5
6b1080e
 
e1b9ef5
 
6b1080e
e1b9ef5
 
 
 
 
6b1080e
e1b9ef5
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
6b1080e
 
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
6b1080e
 
e1b9ef5
 
 
 
6b1080e
e1b9ef5
6b1080e
e1b9ef5
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
 
 
e1b9ef5
6b1080e
e1b9ef5
6b1080e
e1b9ef5
6b1080e
 
 
 
 
 
 
e1b9ef5
6b1080e
e1b9ef5
 
 
 
 
 
 
6b1080e
e1b9ef5
6b1080e
e1b9ef5
6b1080e
e1b9ef5
6b1080e
e1b9ef5
6b1080e
 
e1b9ef5
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
e1b9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1080e
 
e1b9ef5
 
 
 
6b1080e
e1b9ef5
 
6b1080e
e1b9ef5
6b1080e
 
e1b9ef5
 
 
 
 
 
 
 
 
6b1080e
9959147
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
<!doctype html>
<html lang="en" data-wr92-course="det">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta
    name="description"
    content="AI-Powered Object Detection mini-lab using COCO examples and a pretrained model"
  />
  <title>AI-Powered Object Detection</title>

  <link
    rel="icon"
    href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🔎</text></svg>"
  />

  <link rel="stylesheet" href="./style.css" />
<style id="wr92-shared-classroom-nav">
.wr92-course-nav{max-width:1160px;margin:12px auto 0;padding:16px 18px;border:1px solid #dce4f0;border-radius:16px;background:#f8fbff;color:#243047;font-family:system-ui,-apple-system,sans-serif;line-height:1.5}
.wr92-course-nav strong{font-size:0.97rem}
.wr92-course-nav .wr92-nav-row{display:flex;flex-wrap:wrap;gap:8px;margin:9px 0 12px}
.wr92-course-nav a{display:inline-block;padding:7px 10px;border:1px solid #dae2ee;border-radius:9px;background:#fff;color:#1644a3;text-decoration:none;font-size:0.84rem}
.wr92-course-nav a:hover,.wr92-course-nav a:focus-visible{background:#e6efff;text-decoration:underline}
.wr92-course-nav a[aria-current="page"]{border-color:#3d70d2;background:#eaf1ff;font-weight:700}
.wr92-course-nav p{font-size:0.88rem;margin:5px 0;color:#405169}
.wr92-course-nav .wr92-cap{border-top:1px solid #dce4f0;padding-top:10px}
</style>
  <link rel="stylesheet" href="./wr92-language.css">
  <script defer src="./wr92-language.js"></script>
</head>

<body>
<div class="wr92-language-toolbar" role="group" aria-label="Language / 语言">
  <button type="button" data-wr92-lang="en" aria-pressed="true" disabled>EN</button>
  <button type="button" data-wr92-lang="zh" aria-pressed="false" disabled>中文</button>
</div>

  <main class="page-shell">
    <section class="wr92-course-nav" aria-label="WR92 Course links and usage limits"><strong>WR92 Course · Related learning spaces</strong><nav class="wr92-nav-row" aria-label="Switch between course demos"><a href="https://huggingface.co/spaces/wr92-course/README" target="_top" rel="noopener noreferrer">WR92 Course</a><a href="https://huggingface.co/spaces/wr92-course/test" target="_top" rel="noopener noreferrer" aria-current="page">Object Detection</a><a href="https://huggingface.co/spaces/wr92-course/image-generation-lab" target="_top" rel="noopener noreferrer">Image Generation Lab</a><a href="https://huggingface.co/spaces/miyuki17/creative-technology-image-generation" target="_top" rel="noopener noreferrer">SDXL Turbo · GPU</a><a href="https://huggingface.co/spaces/miyuki17/creative-technology-sana-sprint" target="_top" rel="noopener noreferrer">SANA-Sprint · GPU</a></nav><div class="wr92-cap"><strong>No Hugging Face GPU needed</strong><p>Object detection runs in your browser. Hugging Face ZeroGPU minutes and image-generation call caps do NOT apply here. Your device, model downloads, network, and platform availability can still limit usage. <a href="https://huggingface.co/docs/hub/spaces-zerogpu" target="_blank" rel="noopener noreferrer">HF ZeroGPU policy ↗</a></p></div></section>

    <nav class="guide-linkbar" aria-label="Course guide">
      <span>Building your own AI mini app?</span>
      <a href="./how-to-start.html">How to Start <span aria-hidden="true">→</span></a>
      <a href="https://huggingface.co/spaces/wr92-course/image-generation-lab" rel="noopener noreferrer">Image Generation <span aria-hidden="true">↗</span></a>
    </nav>

    <!-- =========================================================
         HERO
    ========================================================== -->
    <header class="hero">

      <p class="eyebrow">
        Creative Technology · Computer Vision
      </p>

      <h1>
        AI-Powered<br />
        Object Detection
      </h1>

      <p class="lede">
        Pick a COCO example or upload your own image.
        Then choose a pretrained detector and let AI answer:
        <strong>
          what objects are here, and where are they?
        </strong>
      </p>

      <div
        class="lesson-strip"
        aria-label="Mini-lab overview"
      >
        <span>
          <b>Task</b>
          Object detection
        </span>

        <span>
          <b>Data</b>
          COCO validation examples
        </span>

        <span>
          <b>Models</b>
          RT-DETR · DETR · YOLOS Tiny
        </span>
      </div>

    </header>


    <!-- =========================================================
         MAIN WORKSPACE
    ========================================================== -->
    <section
      class="workspace"
      aria-label="Object detection mini-lab"
    >

      <!-- =======================================================
           LEFT: CONTROLS
      ======================================================== -->
      <div class="controls card">

        <!-- STEP 1 -->
        <div class="step">

          <span class="step-number">
            1
          </span>

          <div>
            <p class="control-label sample-title">
              Choose an image
            </p>

            <p class="helper">
              Start with a tested COCO example,
              or try a photo of your own.
            </p>
          </div>

        </div>


        <!-- COCO EXAMPLES -->
        <div class="sample-head coco-head">

          <div>
            <p class="input-kicker">
              Start here · COCO examples
            </p>

            <p class="helper">
              Four images are drawn at random
              from 100 bundled COCO validation examples.
            </p>
          </div>

          <button
            id="shuffle-examples"
            class="shuffle-button"
            type="button"
          >
            Shuffle
          </button>

        </div>


        <div
          id="sample-grid"
          class="sample-grid"
          aria-label="COCO example images"
        ></div>


        <!-- OR -->
        <div class="or-row">
          <span>
            or try your own
          </span>
        </div>


        <!-- IMAGE UPLOAD -->
        <label
          class="control-label"
          for="image-input"
        >
          Upload an image
        </label>

        <p class="helper">
          Useful for seeing where the model
          generalizes well—and where it does not.
        </p>

        <input
          id="image-input"
          class="file-input"
          type="file"
          accept="image/*"
        />


        <div class="divider"></div>


        <!-- STEP 2 -->
        <div class="step">

          <span class="step-number">
            2
          </span>

          <div class="grow">

            <label
              class="control-label"
              for="model-select"
            >
              Choose detector
            </label>

            <select
              id="model-select"
              class="model-select"
            ></select>

            <p
              id="model-note"
              class="helper"
            >
              RT-DETR is the recommended classroom default.
            </p>

          </div>

        </div>


        <div class="divider"></div>


        <!-- STEP 3 -->
        <div class="step">

          <span class="step-number">
            3
          </span>

          <div class="grow">

            <div class="slider-row">

              <label
                class="control-label"
                for="threshold"
              >
                Confidence threshold
              </label>

              <output
                id="threshold-value"
                for="threshold"
              >
                0.50
              </output>

            </div>


            <input
              id="threshold"
              type="range"
              min="0.10"
              max="0.95"
              value="0.50"
              step="0.05"
            />


            <p class="helper">
              Higher values only keep predictions
              the model is more confident about.
            </p>

          </div>

        </div>


        <!-- RUN BUTTON -->
        <button
          id="run-button"
          class="run-button"
          type="button"
          disabled
        >
          Run AI Detection
        </button>


        <!-- STATUS -->
        <p
          id="status"
          class="status"
          aria-live="polite"
        >
          Choose a COCO example or upload your own image.
        </p>


        <!-- PROGRESS -->
        <div
          id="progress-wrap"
          class="progress-wrap"
          hidden
        >
          <div
            id="progress-bar"
            class="progress-bar"
          ></div>
        </div>

      </div>


      <!-- =======================================================
           RIGHT: RESULT
      ======================================================== -->
      <div class="result card">

        <div class="result-head">

          <div>

            <p class="section-kicker">
              AI prediction
            </p>

            <h2>
              What did the detector find?
            </h2>

          </div>


          <span
            id="runtime-badge"
            class="badge"
          >
            Waiting
          </span>

        </div>


        <!-- RESULT CANVAS -->
        <div
          id="canvas-wrap"
          class="canvas-wrap empty"
        >

          <canvas
            id="result-canvas"
            aria-label="Detection result"
          ></canvas>

          <p id="canvas-placeholder">
            Choose an image first.
            The original image appears here before detection.
          </p>

        </div>


        <!-- SUMMARY -->
        <div
          id="summary"
          class="summary"
        >
          No detections yet.
        </div>


        <!-- DETECTION TABLE -->
        <div class="table-wrap">

          <table>

            <thead>
              <tr>
                <th>Object</th>
                <th>Confidence</th>
                <th>Bounding box</th>
              </tr>
            </thead>

            <tbody id="detections-body">

              <tr class="empty-row">
                <td colspan="3">
                  Run the detector to see details.
                </td>
              </tr>

            </tbody>

          </table>

        </div>

      </div>

    </section>


    <!-- =========================================================
         EXPLANATION
    ========================================================== -->
    <section class="explain card">

      <p class="section-kicker">
        What you are doing
      </p>


      <h2 class="explain-title">
        Use a learned AI capability instead of rebuilding
        the traditional task from scratch.
      </h2>


      <p class="explain-copy">
        COCO contains everyday-object images with annotations.
        The selected pretrained detector has already learned
        the object-detection task from labeled data.
        In this mini-lab, you can switch models and compare
        how their predictions differ on the same image.
      </p>


      <div
        class="flow"
        aria-label="Object detection flow"
      >

        <span>
          COCO example or your image
        </span>

        <span class="arrow">
          →
        </span>

        <span>
          Selected pretrained detector
        </span>

        <span class="arrow">
          →
        </span>

        <span>
          Boxes + labels + confidence
        </span>

      </div>


      <p class="extension-note">

        <strong>
          Compare models:
        </strong>

        keep the image fixed,
        switch detector,
        and observe how predictions,
        confidence,
        and speed change.

      </p>

    </section>


    <!-- =========================================================
         FOOTER
    ========================================================== -->
    <footer>
      Hosted as a Hugging Face Static Space ·
      Powered by Transformers.js
    </footer>

  </main>


  <!-- ===========================================================
       APP
  ============================================================ -->
  <script
    type="module"
    src="./app.js"
  ></script>

</body>
</html>