Bobby commited on
Commit
ed53557
·
1 Parent(s): 096bd9e

fix: keep GPU quota errors visible in crowd count results

Browse files
Files changed (2) hide show
  1. AGENTS.md +2 -0
  2. app.py +5 -2
AGENTS.md CHANGED
@@ -24,3 +24,5 @@ Type: code
24
  ## Known failure modes
25
  - **crowd.skyebrowse.com showed a login form / "TypeError: Load failed" (resolved 2026-07-02).** The custom-domain proxy forwards `x-forwarded-host` but not `x-forwarded-proto`, so Gradio computed `root_url = http://crowd.skyebrowse.com` and the https page mixed-content-blocked every fetch; Gradio 6 SSR then rendered its login-form fallback (SSR also dropped `launch(head=...)` meta entirely). Fix, both required: `ssr_mode=False` in `launch()` + the `_https_get_root_url` monkeypatch in app.py (upgrades http→https for non-localhost hosts, because CSR still server-renders `theme.css`/`iframeResizer` URLs from the computed root). Do not remove either when upgrading Gradio; re-verify https://crowd.skyebrowse.com in a browser after any Gradio bump.
26
  - **HEIC (iPhone) uploads crashed with `PIL.UnidentifiedImageError` in Gradio preprocessing (resolved 2026-08-04, commit ab675ad).** Gradio's `image_utils.preprocess_image` calls `PIL.Image.open` even with `type="filepath"`, and stock Pillow has no HEIC decoder. Fix: `pillow-heif` in requirements.txt + `register_heif_opener()` at import time in app.py (registers globally in PIL). Verified via live-Space API call with a real .heic.
 
 
 
24
  ## Known failure modes
25
  - **crowd.skyebrowse.com showed a login form / "TypeError: Load failed" (resolved 2026-07-02).** The custom-domain proxy forwards `x-forwarded-host` but not `x-forwarded-proto`, so Gradio computed `root_url = http://crowd.skyebrowse.com` and the https page mixed-content-blocked every fetch; Gradio 6 SSR then rendered its login-form fallback (SSR also dropped `launch(head=...)` meta entirely). Fix, both required: `ssr_mode=False` in `launch()` + the `_https_get_root_url` monkeypatch in app.py (upgrades http→https for non-localhost hosts, because CSR still server-renders `theme.css`/`iframeResizer` URLs from the computed root). Do not remove either when upgrading Gradio; re-verify https://crowd.skyebrowse.com in a browser after any Gradio bump.
26
  - **HEIC (iPhone) uploads crashed with `PIL.UnidentifiedImageError` in Gradio preprocessing (resolved 2026-08-04, commit ab675ad).** Gradio's `image_utils.preprocess_image` calls `PIL.Image.open` even with `type="filepath"`, and stock Pillow has no HEIC decoder. Fix: `pillow-heif` in requirements.txt + `register_heif_opener()` at import time in app.py (registers globally in PIL). Verified via live-Space API call with a real .heic.
27
+
28
+ - Browser failure diagnosis (2026-09-11): the native queue SSE returned `You have exceeded your ZeroGPU runs limit.`; the later HF `by-subdomain` 401 was a secondary status lookup, not proof that counting requires public source. Capture SSE errors before diagnosing from HTTP errors alone. Authenticated counting passed (stadium 1,345 people, 4.66s; cached recount 1.10s). Preserve `gr.Error` text in the count field so quota rejection is visible instead of generic Error; keep prior cached candidates on rejection. Protected visibility was requested through HF settings; anonymous app/config stayed accessible and source stayed inaccessible. No reset time or numerical run cap was provided by HF.
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import json
2
  import hashlib
 
3
  import os
 
4
  import threading
5
  import time
6
 
@@ -175,8 +177,9 @@ def _count_crowd(image_path, threshold, prediction_state, save_images):
175
  if save_images:
176
  save_images_async(image_path, overlay, total)
177
  return overlay, f"{total:,} people", prediction_state
178
- except gr.Error:
179
- raise
 
180
  except Exception as exc:
181
  print(f"count_crowd failed: {exc}", flush=True)
182
  return None, "Crowd counter failed. Please try a smaller image or try again in a minute.", None
 
1
  import json
2
  import hashlib
3
+ import html
4
  import os
5
+ import re
6
  import threading
7
  import time
8
 
 
177
  if save_images:
178
  save_images_async(image_path, overlay, total)
179
  return overlay, f"{total:,} people", prediction_state
180
+ except gr.Error as exc:
181
+ message = html.unescape(re.sub(r"<[^>]+>", "", str(exc.message))).strip()
182
+ return None, message, prediction_state
183
  except Exception as exc:
184
  print(f"count_crowd failed: {exc}", flush=True)
185
  return None, "Crowd counter failed. Please try a smaller image or try again in a minute.", None