HomesteaderLabs commited on
Commit
ba694f9
·
verified ·
1 Parent(s): 7483ac2

Capture router-rejected uploads into private review queue (no data lost)

Browse files
Files changed (1) hide show
  1. game/ui.py +20 -6
game/ui.py CHANGED
@@ -181,13 +181,23 @@ def _contrib_df() -> pd.DataFrame:
181
  return pd.DataFrame([[r["contributor"], r["count"]] for r in rows], columns=_CONTRIB_COLS)
182
 
183
 
184
- def _stump_reject_html() -> str:
 
 
 
 
 
 
 
185
  return (
186
  "<div class='gm-reveal'>"
187
- "<div class='gm-truth-h'>OUT OF DOMAIN</div>"
188
- "<div class='gm-truth' style='color:#57544c'>NOT STORED</div>"
189
- "<div class='gm-species'>The router didn't place this in berry, mushroom, or plant — "
190
- "so it wasn't added to the dataset. Try a clear photo of a wild plant, mushroom, or berry.</div>"
 
 
 
191
  "</div>"
192
  )
193
 
@@ -261,7 +271,11 @@ def build_stump_tab(pipe) -> None:
261
  res = build_result(call)
262
  in_domain = (not res.abstained) or call.get("reason", "") == "low_confidence"
263
  if not in_domain:
264
- return _stump_reject_html(), gr.update()
 
 
 
 
265
  machine = {"species": res.species, "confidence": res.confidence,
266
  "abstained": res.abstained, "safety": res.safety, "domain": res.domain}
267
  status = datastore.append_sighting(image, user_label.strip(), machine, profile.username)
 
181
  return pd.DataFrame([[r["contributor"], r["count"]] for r in rows], columns=_CONTRIB_COLS)
182
 
183
 
184
+ def _stump_unrouted_html(status: str) -> str:
185
+ body = {
186
+ "stored": "<div class='gm-ok'>Saved for review. If it's a real find, you just handed us a "
187
+ "training example the model is missing.</div>",
188
+ "duplicate": "<div class='gm-warn'>Already flagged for review — this one's logged.</div>",
189
+ "disabled": "<div class='gm-warn'>Couldn't save for review (review-queue token scope not set "
190
+ "on the Space).</div>",
191
+ }.get(status, "")
192
  return (
193
  "<div class='gm-reveal'>"
194
+ "<div class='gm-truth-h'>YOU FOUND A GAP</div>"
195
+ "<div class='gm-truth' style='color:#57544c'>OFF THE MAP</div>"
196
+ "<div class='gm-species'>The machine couldn't place this in berry, mushroom, or plant — "
197
+ "the ultimate stump.</div>"
198
+ f"{body}"
199
+ "<div class='gm-abst'>Genuinely off-topic shots (not a wild plant, mushroom, or berry) get "
200
+ "filtered out in review.</div>"
201
  "</div>"
202
  )
203
 
 
271
  res = build_result(call)
272
  in_domain = (not res.abstained) or call.get("reason", "") == "low_confidence"
273
  if not in_domain:
274
+ router = {"domain": call.get("domain", "unknown"),
275
+ "domain_confidence": call.get("domain_confidence", 0.0),
276
+ "reason": call.get("reason", "")}
277
+ status = datastore.append_unrouted(image, user_label.strip(), router, profile.username)
278
+ return _stump_unrouted_html(status), gr.update() # contributor board unchanged
279
  machine = {"species": res.species, "confidence": res.confidence,
280
  "abstained": res.abstained, "safety": res.safety, "domain": res.domain}
281
  status = datastore.append_sighting(image, user_label.strip(), machine, profile.username)