jfrick commited on
Commit
5b0983f
·
verified ·
1 Parent(s): 35bfd03

Update the demo from the repository

Browse files
Files changed (3) hide show
  1. app.py +5 -1
  2. camera.html +5 -1
  3. crescent_moon/demo.py +1 -1
app.py CHANGED
@@ -160,7 +160,11 @@ def frame(jpeg: str, model: str, categories: str, track: bool, session: str) ->
160
  # never pairs the page with modules it cached from an earlier version of the Space.
161
  FRESH = {"Cache-Control": "no-cache"}
162
  WEB_FILES = ("kernels.js", "model.js", "select.js")
163
- RUNTIME = "web/" + hashlib.sha256(b"".join((WEB / n).read_bytes() for n in WEB_FILES)).hexdigest()[:12] + "/"
 
 
 
 
164
 
165
 
166
  def camera_page():
 
160
  # never pairs the page with modules it cached from an earlier version of the Space.
161
  FRESH = {"Cache-Control": "no-cache"}
162
  WEB_FILES = ("kernels.js", "model.js", "select.js")
163
+ RUNTIME = (
164
+ "web/"
165
+ + hashlib.sha256(b"".join((WEB / n).read_bytes() for n in WEB_FILES)).hexdigest()[:12]
166
+ + "/"
167
+ )
168
 
169
 
170
  def camera_page():
camera.html CHANGED
@@ -340,7 +340,11 @@ async function serverFrame(data) {
340
  const events = await (await fetch(`gradio_api/call/frame/${id}`)).text();
341
  const last = events.trim().split("\n\n").pop();
342
  const kind = /^event: (.*)$/m.exec(last)?.[1], body = /^data: (.*)$/m.exec(last)?.[1];
343
- if (kind !== "complete") throw new Error(JSON.parse(body || "null")?.error || body || kind || "no answer");
 
 
 
 
344
  return JSON.parse(body)[0];
345
  }
346
 
 
340
  const events = await (await fetch(`gradio_api/call/frame/${id}`)).text();
341
  const last = events.trim().split("\n\n").pop();
342
  const kind = /^event: (.*)$/m.exec(last)?.[1], body = /^data: (.*)$/m.exec(last)?.[1];
343
+ if (kind !== "complete") {
344
+ // Gradio hides the reason; on ZeroGPU it is nearly always the visitor's GPU allowance.
345
+ throw new Error(JSON.parse(body || "null")?.error
346
+ || "no GPU time for this visitor (sign in on huggingface.co, or use the model that runs on this device)");
347
+ }
348
  return JSON.parse(body)[0];
349
  }
350
 
crescent_moon/demo.py CHANGED
@@ -1,4 +1,4 @@
1
- """Drawing and video helpers for the detection demo (`demo_app.py`).
2
 
3
  A detection is (label, [x0, y0, x1, y1]) in pixels of the image it was found in.
4
  """
 
1
+ """Drawing and video helpers for the detection demo (`space/app.py`).
2
 
3
  A detection is (label, [x0, y0, x1, y1]) in pixels of the image it was found in.
4
  """