cisdeli commited on
Commit
4a09df2
·
1 Parent(s): 71b2c50

Pin the Space runtime to the environment that reproduces the paper

Browse files

The Space installed ultralytics/torch unpinned, and on the identical bundled
image it reported 671.73 in2 of projected area against 737.40 in2 locally,
with 6 tubers shifting out of OV. Detections were identical, so the drift is
in mask post-processing, which is version-dependent.

Pin the app's runtime to the locked local versions and log them at startup so
a future drift is visible in the Space logs.

Files changed (2) hide show
  1. app/app.py +7 -0
  2. app/requirements.txt +14 -5
app/app.py CHANGED
@@ -53,6 +53,13 @@ USDA_COLORS: dict[str, tuple[int, int, int]] = {
53
  }
54
  UNKNOWN_COLOR = (180, 180, 180)
55
 
 
 
 
 
 
 
 
56
  print(f"[app] weights: {WEIGHTS_PATH}")
57
  print(f"[app] coefficients: {COEFS_PATH}")
58
  print(f"[app] dataset: {DATASET_ROOT}")
 
53
  }
54
  UNKNOWN_COLOR = (180, 180, 180)
55
 
56
+ import importlib.metadata as _md
57
+
58
+ # Mask geometry depends on these versions; log them so a Space build that
59
+ # drifts from the pinned environment is visible in the runtime logs.
60
+ print("[app] versions: " + ", ".join(
61
+ f"{_p}={_md.version(_p)}" for _p in ("ultralytics", "torch", "numpy", "opencv-python")
62
+ ))
63
  print(f"[app] weights: {WEIGHTS_PATH}")
64
  print(f"[app] coefficients: {COEFS_PATH}")
65
  print(f"[app] dataset: {DATASET_ROOT}")
app/requirements.txt CHANGED
@@ -1,6 +1,15 @@
1
- numpy>=1.26
2
- pandas>=2.2
3
- pillow>=10.0
4
- scikit-learn>=1.5
5
- ultralytics>=8.3
 
 
 
 
 
 
 
 
 
6
  gradio>=4.0
 
1
+ # Pinned to the environment that reproduces the published per-tuber CSV.
2
+ # Mask geometry (and therefore USDA class assignment) depends on the
3
+ # Ultralytics/PyTorch versions, so the Space must not float these.
4
+ --extra-index-url https://download.pytorch.org/whl/cpu
5
+
6
+ torch==2.11.0
7
+ torchvision==0.26.0
8
+ ultralytics==8.4.48
9
+ opencv-python==4.13.0.92
10
+ numpy==2.4.4
11
+ pandas==3.0.2
12
+ pillow==12.2.0
13
+ scikit-learn==1.8.0
14
+ scipy==1.17.1
15
  gradio>=4.0