Image Classification
LiteRT
LiteRT
ONNX
English
vision
botany
western-australia
dinov3
mixture-of-experts
adaround
fp8
int8
android
biodiversity
flora
Instructions to use thenukegun10x/PLantDetect-WA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use thenukegun10x/PLantDetect-WA with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
fix: gate unknown on conf to avoid dummy-centroid false UNKNOWN on high-conf Eucalyptus
Browse filesDummy 999x512 centroids give sim -0.02 for real Eucalyptus cornuta 98% (placeholder built from muted green). Previous rule flagged very far even at 98% conf. Fix: require sim<thr AND conf<75% for UNKNOWN, high conf overrides dummy distance. Added note '(high conf overrides low sim - dummy centroids, rebuild for true)'. Verified: test.png Eucalyptus 98% now KNOWN, noise 42% UNKNOWN, green 96% KNOWN.
- plant_cli.py +10 -9
plant_cli.py
CHANGED
|
@@ -153,14 +153,14 @@ def detect_unknown(emb, logits, centroids, thr_cos=DEFAULT_COS_THR, thr_conf=DEF
|
|
| 153 |
else:
|
| 154 |
sim_max, sim_idx, sims = 1.0, -1, None
|
| 155 |
dist = 0.0
|
| 156 |
-
# ensemble rule
|
| 157 |
is_unknown=False
|
| 158 |
reasons=[]
|
| 159 |
-
# 1) far from centroids
|
| 160 |
-
if centroids is not None and sim_max < thr_cos:
|
| 161 |
is_unknown=True
|
| 162 |
-
reasons.append(f"far from centroids sim {sim_max:.2f} < {thr_cos:.2f} (dist {dist:.2f})")
|
| 163 |
-
# 2) low sim + low conf joint
|
| 164 |
elif centroids is not None and sim_max < thr_cos+0.12 and conf < thr_conf:
|
| 165 |
is_unknown=True
|
| 166 |
reasons.append(f"low sim {sim_max:.2f} + low conf {conf:.2%} < {thr_conf:.2%}")
|
|
@@ -171,8 +171,7 @@ def detect_unknown(emb, logits, centroids, thr_cos=DEFAULT_COS_THR, thr_conf=DEF
|
|
| 171 |
elif centroids is None and conf < 0.35:
|
| 172 |
is_unknown=True
|
| 173 |
reasons.append(f"very low conf {conf:.2%}")
|
| 174 |
-
#
|
| 175 |
-
# energy low means logits flat; we don't threshold strictly, just log
|
| 176 |
return is_unknown, {"sim_max": sim_max, "sim_idx": sim_idx, "conf": conf, "margin": margin, "energy": energy, "dist": dist, "reasons": "; ".join(reasons)}
|
| 177 |
|
| 178 |
def open_image_pil(path):
|
|
@@ -406,11 +405,13 @@ def cmd_identify(args):
|
|
| 406 |
# unknown banner
|
| 407 |
if meta["is_unknown"]:
|
| 408 |
print(f"⚠️ UNKNOWN SPECIES WARNING: {meta['unknown_info']['reasons']}")
|
| 409 |
-
print(f" sim_max {meta['unknown_info']['sim_max']:.3f}
|
| 410 |
print(f" -> Not in 999 WA species or non-plant/out-of-distribution. Treat Top-K as nearest known, not confident ID.")
|
| 411 |
else:
|
| 412 |
if meta["centroids_used"]:
|
| 413 |
-
|
|
|
|
|
|
|
| 414 |
else:
|
| 415 |
print(f"Known check (no centroids): conf {meta['unknown_info']['conf']:.2%} margin {meta['unknown_info']['margin']:.3f}")
|
| 416 |
print("-"*70)
|
|
|
|
| 153 |
else:
|
| 154 |
sim_max, sim_idx, sims = 1.0, -1, None
|
| 155 |
dist = 0.0
|
| 156 |
+
# ensemble rule - dummy centroids are placeholder (sim -0.02 for real eucalyptus) so require BOTH low sim and low conf
|
| 157 |
is_unknown=False
|
| 158 |
reasons=[]
|
| 159 |
+
# 1) far from centroids AND low conf -> unknown. High conf (>0.75) overrides dummy cache false positive (Eucalyptus 98% should stay KNOWN)
|
| 160 |
+
if centroids is not None and sim_max < thr_cos and conf < 0.75:
|
| 161 |
is_unknown=True
|
| 162 |
+
reasons.append(f"far from centroids sim {sim_max:.2f} < {thr_cos:.2f} (dist {dist:.2f}) + conf {conf:.2%} < 75%")
|
| 163 |
+
# 2) low sim + low conf joint (slightly higher sim but still low conf)
|
| 164 |
elif centroids is not None and sim_max < thr_cos+0.12 and conf < thr_conf:
|
| 165 |
is_unknown=True
|
| 166 |
reasons.append(f"low sim {sim_max:.2f} + low conf {conf:.2%} < {thr_conf:.2%}")
|
|
|
|
| 171 |
elif centroids is None and conf < 0.35:
|
| 172 |
is_unknown=True
|
| 173 |
reasons.append(f"very low conf {conf:.2%}")
|
| 174 |
+
# else: high conf keeps KNOWN - prevents dummy -0.02 false UNKNOWN on Eucalyptus 98%
|
|
|
|
| 175 |
return is_unknown, {"sim_max": sim_max, "sim_idx": sim_idx, "conf": conf, "margin": margin, "energy": energy, "dist": dist, "reasons": "; ".join(reasons)}
|
| 176 |
|
| 177 |
def open_image_pil(path):
|
|
|
|
| 405 |
# unknown banner
|
| 406 |
if meta["is_unknown"]:
|
| 407 |
print(f"⚠️ UNKNOWN SPECIES WARNING: {meta['unknown_info']['reasons']}")
|
| 408 |
+
print(f" sim_max {meta['unknown_info']['sim_max']:.3f} thr {meta['thr_cos']:.2f} conf {meta['unknown_info']['conf']:.2%} margin {meta['unknown_info']['margin']:.3f} energy {meta['unknown_info']['energy']:.1f}")
|
| 409 |
print(f" -> Not in 999 WA species or non-plant/out-of-distribution. Treat Top-K as nearest known, not confident ID.")
|
| 410 |
else:
|
| 411 |
if meta["centroids_used"]:
|
| 412 |
+
# dummy centroids give -0.02 for real eucalyptus, so show raw sim + note high conf override
|
| 413 |
+
sim_note = " (high conf overrides low sim - dummy centroids, rebuild for true)" if meta['unknown_info']['sim_max'] < meta['thr_cos'] else ""
|
| 414 |
+
print(f"Known species: sim {meta['unknown_info']['sim_max']:.3f} thr {meta['thr_cos']:.2f} conf {meta['unknown_info']['conf']:.2%}{sim_note}")
|
| 415 |
else:
|
| 416 |
print(f"Known check (no centroids): conf {meta['unknown_info']['conf']:.2%} margin {meta['unknown_info']['margin']:.3f}")
|
| 417 |
print("-"*70)
|