keejkrej commited on
Commit
aac4fd9
·
verified ·
1 Parent(s): e0c5dcd

Add README.md

Browse files
Files changed (1) hide show
  1. README.md +104 -0
README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - image-segmentation
5
+ - onnx
6
+ - biology
7
+ - microscopy
8
+ - cell-segmentation
9
+ - micropattern
10
+ pipeline_tag: image-segmentation
11
+ library_name: onnx
12
+ ---
13
+
14
+ # Single-cell pattern U-Net (`single-cell-pattern-unet`)
15
+
16
+ Small dense **foreground / background** segmenter for **LISCA micropattern**
17
+ brightfield ROI crops (~128×128 single-cell sites).
18
+
19
+ Use it whenever you need a binary cell mask on a patterned site (gene-expression
20
+ intensity, binding overlays, etc.) without running full Cellpose cpsam.
21
+
22
+ Published as: **[keejkrej/single-cell-pattern-unet](https://huggingface.co/keejkrej/single-cell-pattern-unet)**
23
+
24
+ ## Why not full Cellpose cpsam?
25
+
26
+ cpsam (ViT-L, ~304M) is excellent as a **teacher** for pseudo-labels, but
27
+ production masks only need binary foreground for intensity / area metrics.
28
+ This student U-Net (~1.9M params, ~7.4 MB ONNX) is distilled from cpsam labels
29
+ on in-house TF84 BF frames.
30
+
31
+ Teacher weights are CC-BY-NC; this student is trained on your images only.
32
+
33
+ ## Files
34
+
35
+ ```text
36
+ onnx/model.onnx # inference graph
37
+ export_meta.json # preprocess / postprocess contract
38
+ README.md
39
+ ```
40
+
41
+ Local checkout path in the lisca monorepo is still
42
+ `models/gene-expression-fg-unet/` (historical); the Hugging Face id is the
43
+ canonical name.
44
+
45
+ ## Metrics (TF84 hold-out positions)
46
+
47
+ | Split | Samples | Best val Dice |
48
+ |-------|--------:|--------------:|
49
+ | train | 41,548 | — |
50
+ | val | 6,990 | **0.888** (epoch 18) |
51
+
52
+ Teacher: Cellpose v4 **cpsam**, time stride 20, empty masks dropped
53
+ (`fg < 0.1%`).
54
+
55
+ ## Preprocess / postprocess
56
+
57
+ Matches `export_meta.json`:
58
+
59
+ 1. Min–max normalize BF crop → uint8
60
+ 2. Resize to 128×128
61
+ 3. Grayscale → RGB, ImageNet mean/std
62
+ 4. ONNX `logits` `(N,1,128,128)` → sigmoid ≥ 0.5
63
+ 5. Nearest resize to original H×W, hole fill
64
+
65
+ ### ONNX I/O
66
+
67
+ | | Name | Shape |
68
+ |--|------|-------|
69
+ | input | `pixel_values` | `(N, 3, 128, 128)` float32 |
70
+ | output | `logits` | `(N, 1, 128, 128)` float32 |
71
+
72
+ ## Inference (lisca Rust)
73
+
74
+ ```sh
75
+ # download
76
+ huggingface-cli download keejkrej/single-cell-pattern-unet \
77
+ --local-dir ./models/gene-expression-fg-unet
78
+
79
+ export LISCA_GE_SEG_MODEL=./models/gene-expression-fg-unet/onnx
80
+ lisca-analyze segment ~/data/TF84 --backend onnx --force
81
+ ```
82
+
83
+ ## Train (from `lisca/python`)
84
+
85
+ ```sh
86
+ cd python && uv sync --group train
87
+
88
+ uv run lisca dataset label-cpsam \
89
+ --workspace ~/data/TF84 --output ~/data/TF84/cpsam_labels \
90
+ --channel 0 --time-stride 20
91
+
92
+ uv run lisca dataset create-gene-expression-seg \
93
+ --labels ~/data/TF84/cpsam_labels --output ~/data/TF84/ge_seg_dataset
94
+
95
+ uv run lisca dataset train-gene-expression-seg \
96
+ --dataset ~/data/TF84/ge_seg_dataset --output ~/data/TF84/ge_seg_runs \
97
+ --epochs 40 --image-size 128
98
+ ```
99
+
100
+ ## Env
101
+
102
+ | Variable | Meaning |
103
+ |----------|---------|
104
+ | `LISCA_GE_SEG_MODEL` | Directory containing `model.onnx` (or path to the file) |