Commit
·
fec3b29
1
Parent(s):
b0073d4
Add-README.md
Browse files- README.md +81 -0
- first.text +0 -0
README.md
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 🧠 UNet Fibril Segmentation Model
|
2 |
+
|
3 |
+

|
4 |
+
|
5 |
+
A **UNet-based deep learning model** trained for **semantic segmentation of fibrillar structures** in **single-molecule fluorescence microscopy images**. This model is specifically designed to identify and segment **amyloid fibrils**, which are critical in research related to neurodegenerative diseases such as Alzheimer’s.
|
6 |
+
|
7 |
+
---
|
8 |
+
|
9 |
+
## 🔬 Model Overview
|
10 |
+
|
11 |
+
- **Architecture**: [UNet](https://arxiv.org/abs/1505.04597)
|
12 |
+
- **Encoder**: ResNet34 (pretrained on ImageNet)
|
13 |
+
- **Input Channels**: 1 (grayscale)
|
14 |
+
- **Output**: Binary mask of fibril regions
|
15 |
+
- **Loss Function**: BCEWithLogitsLoss / Dice Loss (combined)
|
16 |
+
- **Framework**: PyTorch + [segmentation_models.pytorch](https://github.com/qubvel/segmentation_models.pytorch)
|
17 |
+
|
18 |
+
---
|
19 |
+
|
20 |
+
## 🧠 Use Case
|
21 |
+
|
22 |
+
The model is built for biomedical researchers and computer vision practitioners working in:
|
23 |
+
|
24 |
+
- **Neuroscience research** (e.g., Alzheimer's, Parkinson’s)
|
25 |
+
- **Amyloid aggregation studies**
|
26 |
+
- **Single-molecule fluorescence microscopy**
|
27 |
+
- **Self-supervised denoising + segmentation pipelines**
|
28 |
+
|
29 |
+
---
|
30 |
+
|
31 |
+
## 🧪 Dataset
|
32 |
+
|
33 |
+
The model was trained on a curated dataset of **fluorescence microscopy images** annotated for fibrillar structures. Images were grayscale, of size `512x512` or `256x256`, manually labeled using Fiji/ImageJ or custom annotation tools.
|
34 |
+
|
35 |
+
*Note: If you're a researcher and would like to contribute more annotated data or collaborate on a dataset release, please reach out.*
|
36 |
+
|
37 |
+
---
|
38 |
+
|
39 |
+
## 📦 Files
|
40 |
+
|
41 |
+
- `unet_fibril_seg_model.pth` — Trained PyTorch weights
|
42 |
+
- `inference.py` — Inference script for running the model
|
43 |
+
- `preprocessing.py` — Image normalization and transforms
|
44 |
+
|
45 |
+
---
|
46 |
+
|
47 |
+
## 🖼️ Example
|
48 |
+
|
49 |
+
```python
|
50 |
+
import torch
|
51 |
+
import numpy as np
|
52 |
+
from PIL import Image
|
53 |
+
from torchvision import transforms
|
54 |
+
import segmentation_models_pytorch as smp
|
55 |
+
|
56 |
+
# Load model
|
57 |
+
model = smp.Unet(
|
58 |
+
encoder_name="resnet34",
|
59 |
+
encoder_weights="imagenet",
|
60 |
+
in_channels=1,
|
61 |
+
classes=1,
|
62 |
+
)
|
63 |
+
model.load_state_dict(torch.load("unet_fibril_seg_model.pth", map_location="cpu"))
|
64 |
+
model.eval()
|
65 |
+
|
66 |
+
# Load image
|
67 |
+
img = Image.open("test_image.png").convert("L")
|
68 |
+
transform = transforms.Compose([
|
69 |
+
transforms.Resize((256, 256)),
|
70 |
+
transforms.ToTensor()
|
71 |
+
])
|
72 |
+
input_tensor = transform(img).unsqueeze(0)
|
73 |
+
|
74 |
+
# Predict
|
75 |
+
with torch.no_grad():
|
76 |
+
pred = model(input_tensor)
|
77 |
+
pred_mask = torch.sigmoid(pred).squeeze().numpy()
|
78 |
+
binary_mask = (pred_mask > 0.5).astype(np.uint8)
|
79 |
+
|
80 |
+
# Save output
|
81 |
+
Image.fromarray(binary_mask * 255).save("predicted_mask.png")
|
first.text
DELETED
File without changes
|