File size: 2,687 Bytes
c006407 2b9ff22 a479866 2b9ff22 bf0c277 2b9ff22 a479866 2b9ff22 a479866 0a0e144 a479866 2b9ff22 a479866 2b9ff22 a479866 2b9ff22 a479866 2b9ff22 63c07ee 2b9ff22 daa6938 2b58c1c daa6938 a479866 2b58c1c 2b9ff22 2b58c1c 2b9ff22 2b58c1c 2b9ff22 2b58c1c 2b9ff22 a479866 2b9ff22 2b58c1c 2b9ff22 2b58c1c 2b9ff22 2b58c1c 2b9ff22 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | ---
tags:
- biology
- microscopy
- traction-force
- pytorch
- pix2pix
- gan
license: mit
---
# Shape2Force (S2F)
Predict force maps from bright-field microscopy images of single-cell or spheroid.
If you find this software useful, please cite:
Lautaro Baro#, Kaveh Shahhosseini#, Amparo Andrés-Bordería, Claudio Angione*, and Maria Angeles Juanes*. **"Shape-to-force (S2F): Predicting Cell Traction Forces from LabelFree Imaging"**, 2026.
---
## Ways to Use S2F
### 1. Web App (local)
Run the Streamlit GUI from `S2FApp/`:
```bash
git clone https://github.com/Angione-Lab/Shape2Force.git
cd Shape2Force/S2FApp
pip install -r requirements.txt
streamlit run app.py
```
1. Choose Model type: Single cell or Spheroid
2. Place checkpoints (`.pth`) in `S2FApp/ckp/` for local use.
3. Select a Checkpoint from `ckp/`
4. For single-cell: pick Substrate (e.g. fibroblasts_PDMS)
5. Upload an image or pick from `samples/`
6. Click Run prediction
---
### 2. Web App Online
Use the [online app](https://huggingface.co/spaces/Angione-Lab/Shape2force) on Hugging Face.
<p align="center">
<img src="./S2FApp/res/ss.png" width="450" alt="Shape2Force Web App" />
</p>
---
### 3. Jupyter Notebooks
For interactive usage and custom analysis, use the notebooks in `notebooks/`:
- **`notebooks/Singlecell_inference.ipynb`** – Load a folder of brightfield images, run single-cell predictions, plot samples, and save all predictions with metrics.
- **`notebooks/Singlecell_evaluation.ipynb`** – Evaluate single-cell model on a dataset with ground truth; compute metrics and plot predictions.
- **`notebooks/Spheroid_inference.ipynb`** – Run spheroid predictions on brightfield images, plot samples, and save predictions.
- **`notebooks/Spheroid_evaluation.ipynb`** – Evaluate spheroid model on as dataset with ground truth; compute metrics and plot predictions.
Once cloned, open a notebook in Jupyter and adjust the configuration cell (paths, model type, substrate).
---
### 4. Training & Fine-Tuning
**Dataset layout:** A folder with `train/` and `test/` subfolders. Each subfolder has:
- `BF_001.tif` (bright-field image)
- `*_gray.jpg` (force map / heatmap)
- Optional `.txt` (cell_area, sum_force)
**Single-cell:**
```bash
python -m training.train \
--data path/to/dataset \
--model single_cell \
--epochs 100 \
--substrate fibroblasts_PDMS
```
**Spheroid:**
```bash
python -m training.train \
--data path/to/dataset \
--model spheroid \
--epochs 100
```
**Resume / fine-tune from checkpoint:**
```bash
python -m training.train \
--data path/to/dataset \
--model single_cell \
--resume ckp/last_checkpoint.pth \
--epochs 150
```
---
|