Marconcini commited on
Commit
a2fca43
·
verified ·
1 Parent(s): 38dda9b

Add ONNX exports (fp32, int8 recalibrated) for the in-browser demo (code @ 54b1aaf)

Browse files
Files changed (4) hide show
  1. README.md +12 -2
  2. config.json +6 -1
  3. model.onnx +3 -0
  4. model_int8.onnx +3 -0
README.md CHANGED
@@ -53,8 +53,18 @@ print(pred.verdict) # diagnosis, or "Not sure" below the field-calibrated thre
53
  print(pred.top) # top-3 (class, calibrated probability)
54
  ```
55
 
56
- Files: `model.safetensors` (weights) and `config.json` (class names, input size, temperature,
57
- threshold).
 
 
 
 
 
 
 
 
 
 
58
 
59
  ## Intended use and limitations
60
 
 
53
  print(pred.top) # top-3 (class, calibrated probability)
54
  ```
55
 
56
+ Files:
57
+ - `model.safetensors` — PyTorch weights; `config.json` — class names, input size, temperature,
58
+ threshold (and those of the int8 model under `onnx_int8`).
59
+ - `model.onnx` — fp32 ONNX export, identical top-1 to PyTorch on PlantDoc test.
60
+ - `model_int8.onnx` — 32 MB, linear layers quantised to int8 (convolutions kept fp32, as ONNX
61
+ Runtime Web has no int8 convolution). Used by the in-browser demo. Same predictions as fp32
62
+ on 96.5% of PlantDoc test photos; 71.9% accuracy. Because quantisation changes some
63
+ predictions, it has **its own temperature and threshold**, refitted on the same field
64
+ calibration set: on PlantDoc test it answers 66% of photos, 84.7% of them right.
65
+
66
+ In the browser (ONNX Runtime Web, image resizing done by the canvas instead of PIL), the demo
67
+ agrees with the Python int8 predictions on 96.1% of PlantDoc test photos.
68
 
69
  ## Intended use and limitations
70
 
config.json CHANGED
@@ -44,5 +44,10 @@
44
  "temperature": 0.8288379907608032,
45
  "threshold": 0.7529807090759277,
46
  "threshold_target_accuracy": 0.9,
47
- "trained_on": "PlantVillage, then 85% of PlantDoc train"
 
 
 
 
 
48
  }
 
44
  "temperature": 0.8288379907608032,
45
  "threshold": 0.7529807090759277,
46
  "threshold_target_accuracy": 0.9,
47
+ "trained_on": "PlantVillage, then 85% of PlantDoc train",
48
+ "onnx_int8": {
49
+ "file": "model_int8.onnx",
50
+ "temperature": 0.8375558853149414,
51
+ "threshold": 0.747735857963562
52
+ }
53
  }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e4917ac524318a76e9701c91a91fdb83a4eecac2cf5a4391ef1151a651885d9
3
+ size 111475217
model_int8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9157f0637787cf8cde6f94dac96ca42f5e59ef8614048dc0777962a571f4231d
3
+ size 33832676