[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-11270":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":20,"topics":21,"createdAt":9,"pushedAt":9,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":14,"starSnapshotCount":14,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},11270,"ophthalmic-segmentation","FeiFeiAlbert\u002Fophthalmic-segmentation","FeiFeiAlbert","High-accuracy UNet++ ophthalmic fundus image segmentation with Val Dice 0.9554",null,"Python",117,3,4,0,50,46.81,"MIT License",false,"main",true,[],"2026-06-12 04:00:54","# Eye Fundus Image Segmentation\r\n\r\n\u003Cdiv align=\"center\">\r\n\r\n[![PyPI Version](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fophthalmic-segmentation)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fophthalmic-segmentation\u002F)\r\n[![Python](https:\u002F\u002Fimg.shields.io\u002Fpython\u002Frequired version-toml-python-prj)](https:\u002F\u002Fpypi.org)\r\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-blue.svg)](LICENSE)\r\n[![Model Dice](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FVal%20Dice-0.9554-brightgreen)](docs\u002Fresults.md)\r\n\r\n**High-accuracy UNet++ 眼底图像分割模型 for multi-class retinal image segmentation.**\r\n\r\n[English](README.md) | [中文](README_zh.md)\r\n\r\n\u003C\u002Fdiv>\r\n\r\n---\r\n\r\n## ✨ Features\r\n\r\n- **High Accuracy**: Val Dice = **0.9554** (V16 with hot-start from V13)\r\n- **Multi-class Segmentation**: Background, ROI (Retinal Region), Valid Reflex\r\n- **V16 Training Script**: Complete training with Combined Loss (Focal + Dice + Lovasz)\r\n- **4-Direction TTA**: Test-Time Augmentation for robust predictions\r\n- **Hot-Start Training**: Start from V13 pretrained weights for faster convergence\r\n- **Pre-trained Models**: Ready-to-use checkpoints\r\n- **Real Model Inference**: Load trained model and predict on new images\r\n\r\n## 📊 Performance\r\n\r\n| Metric | Score |\r\n|--------|-------|\r\n| Val Dice (no TTA) | **0.9554** |\r\n| Val Dice (4x TTA) | **0.9398** |\r\n| ROI Dice | 0.9282 |\r\n| Reflex Dice | 0.9660 |\r\n\r\n## 🖼️ Example Results\r\n\r\nReal segmentation results from the v16 model:\r\n\r\n\u003Ctable>\r\n\u003Ctr>\r\n\u003Ctd align=\"center\">\u003Cb>Original\u003C\u002Fb>\u003C\u002Ftd>\r\n\u003Ctd align=\"center\">\u003Cb>Prediction Mask\u003C\u002Fb>\u003C\u002Ftd>\r\n\u003Ctd align=\"center\">\u003Cb>Overlay\u003C\u002Fb>\u003C\u002Ftd>\r\n\u003C\u002Ftr>\r\n\u003Ctr>\r\n\u003Ctd colspan=\"3\">\r\n\r\n![Example 1](examples\u002Fexample_1.png)\r\n\r\n\u003C\u002Ftd>\r\n\u003C\u002Ftr>\r\n\u003Ctr>\r\n\u003Ctd colspan=\"3\">\r\n\r\n![Example 2](examples\u002Fexample_2.png)\r\n\r\n\u003C\u002Ftd>\r\n\u003C\u002Ftr>\r\n\u003Ctr>\r\n\u003Ctd colspan=\"3\">\r\n\r\n![Example 3](examples\u002Fexample_3.png)\r\n\r\n\u003C\u002Ftd>\r\n\u003C\u002Ftr>\r\n\u003C\u002Ftable>\r\n\r\nMore examples: [examples\u002F](https:\u002F\u002Fgithub.com\u002FFeiFeiAlbert\u002Fophthalmic-segmentation\u002Ftree\u002Fmain\u002Fexamples)\r\n\r\n## 🏗️ Architecture\r\n\r\n```\r\nUNet++ with EfficientNet-B4 encoder\r\n├── Input: 448×448×3 RGB image\r\n├── Encoder: EfficientNet-B4 (ImageNet pretrained)\r\n├── Decoder: UNet++ dense skip connections\r\n└── Output: 448×448×3 segmentation mask\r\n    ├── Class 0: Background (black)\r\n    ├── Class 1: ROI - Retinal Region (green)\r\n    └── Class 2: Valid Reflex (red)\r\n```\r\n\r\n## 🔧 Installation\r\n\r\n```bash\r\npip install ophthalmic-segmentation\r\n```\r\n\r\nOr install from source:\r\n\r\n```bash\r\ngit clone https:\u002F\u002Fgithub.com\u002FFeiFeiAlbert\u002Fophthalmic-segmentation.git\r\ncd ophthalmic-segmentation\r\npip install -e .\r\n```\r\n\r\n### Dependencies\r\n\r\n```\r\ntorch >= 2.0.0\r\ntorchvision >= 0.15.0\r\nsegmentation-models-pytorch >= 0.3.3\r\nalbumentations >= 1.3.1\r\nopencv-python >= 4.8.0\r\npillow >= 10.0.0\r\nmatplotlib >= 3.7.0\r\nnumpy >= 1.24.0\r\ntqdm >= 4.65.0\r\n```\r\n\r\n## 🚀 Quick Start\r\n\r\n### 1. Use Pre-trained Model (Recommended)\r\n\r\n```python\r\nimport torch\r\nfrom ophthalmic_segmentation.model import create_model\r\nfrom ophthalmic_segmentation import FundusSegmenter\r\n\r\n# Create model\r\nsegmenter = FundusSegmenter.create_model(\r\n    architecture='unetpp', \r\n    encoder='efficientnet-b4', \r\n    num_classes=3\r\n)\r\n\r\n# Load pretrained weights\r\nsegmenter.load_checkpoint('checkpoints\u002Fbest_model.pth')\r\n\r\n# Predict on image\r\nfrom PIL import Image\r\nimage = Image.open('path\u002Fto\u002Ffundus_image.jpg')\r\nmask = segmenter.predict(image, input_size=448, apply_tta=True)\r\n\r\n# Visualize\r\noverlay = segmenter.visualize(image, mask, alpha=0.5)\r\n```\r\n\r\n### 2. Train Your Own Model (V16)\r\n\r\nTrain from scratch or with hot-start from V13:\r\n\r\n```bash\r\n# Train with V16 (from scratch, ImageNet pretrained encoder)\r\npython scripts\u002Ftrain_v16.py \\\r\n    --data_dir .\u002Fdata \\\r\n    --img_size 448 \\\r\n    --batch_size 4 \\\r\n    --epochs 200 \\\r\n    --save_dir checkpoints\r\n\r\n# Train with hot-start from V13 weights\r\npython scripts\u002Ftrain_v16.py \\\r\n    --data_dir .\u002Fdata \\\r\n    --pretrained checkpoints_v13\u002Fbest_model.pth \\\r\n    --img_size 448 \\\r\n    --batch_size 4 \\\r\n    --epochs 200 \\\r\n    --save_dir checkpoints_v16\r\n```\r\n\r\n**V16 Key Features:**\r\n- Combined Loss: 0.3×Focal + 0.4×Dice + 0.3×Lovasz\r\n- Differential Learning Rates: encoder=1e-5, decoder=1e-4\r\n- CosineAnnealingWarmRestarts scheduler (T₀=50, T_mult=2)\r\n- 4-direction TTA validation\r\n- Early stopping with patience=50\r\n\r\n### 3. Run Inference\r\n\r\n```bash\r\n# Single image inference with TTA\r\npython scripts\u002Fpredict.py \\\r\n    --model checkpoints\u002Fbest_model.pth \\\r\n    --input path\u002Fto\u002Fimage.jpg \\\r\n    --output result.png\r\n\r\n# Batch processing\r\npython scripts\u002Fpredict.py \\\r\n    --model checkpoints\u002Fbest_model.pth \\\r\n    --input data\u002Fimages\u002F \\\r\n    --output results\u002F\r\n\r\n# Without TTA (faster but less accurate)\r\npython scripts\u002Fpredict.py \\\r\n    --model checkpoints\u002Fbest_model.pth \\\r\n    --input image.jpg \\\r\n    --output result.png \\\r\n    --no-tta\r\n```\r\n\r\n## 📂 Project Structure\r\n\r\n```\r\nophthalmic-segmentation\u002F\r\n├── README.md\r\n├── README_zh.md\r\n├── LICENSE (MIT)\r\n├── requirements.txt\r\n├── setup.py\r\n├── examples\u002F              # Example segmentation results\r\n│   ├── example_1.png\r\n│   ├── example_2.png\r\n│   └── example_3.png\r\n├── ophthalmic_segmentation\u002F\r\n│   ├── __init__.py         # Package exports\r\n│   ├── model.py            # Model definition (UNet++, DeepLabV3+, etc.)\r\n│   ├── data.py             # Dataset class with augmentation\r\n│   ├── losses.py           # Focal, Dice, Lovasz, CombinedLoss\r\n│   └── utils.py            # Utility functions\r\n├── scripts\u002F\r\n│   ├── train_v16.py        # V16 training script (FULL version)\r\n│   ├── train.py             # Simplified training script\r\n│   └── predict.py           # V16 inference script\r\n├── checkpoints\u002F\r\n│   └── best_model.pth      # Pre-trained weights (V16)\r\n├── docs\u002F\r\n│   ├── training_report.md   # Detailed training log\r\n│   └── results.md          # Evaluation results\r\n└── tests\u002F\r\n    └── test_model.py       # Unit tests\r\n```\r\n\r\n## 📖 Documentation\r\n\r\n- [Training Report](docs\u002Ftraining_report.md) - Detailed V16 training process and results\r\n- [Results Analysis](docs\u002Fresults.md) - Performance metrics and comparisons\r\n- [Examples](examples\u002F) - Visual segmentation results\r\n\r\n## 🔬 Segmentation Classes\r\n\r\n| Class | Color | Description |\r\n|-------|-------|-------------|\r\n| 0: Background | Black | Non-retinal regions |\r\n| 1: ROI | Green | Retinal region of interest |\r\n| 2: Valid Reflex | Red | Valid red reflex area |\r\n\r\n## 📜 Citation\r\n\r\nIf this project helps your research, please cite:\r\n\r\n```bibtex\r\n@misc{ophthalmic-segmentation,\r\n  title={Ophthalmic Fundus Image Segmentation with UNet++},\r\n  author={Albert Long},\r\n  year={2026},\r\n  howpublished={\\url{https:\u002F\u002Fgithub.com\u002FFeiFeiAlbert\u002Fophthalmic-segmentation}}\r\n}\r\n```\r\n\r\n## 📄 License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## 🙏 Acknowledgments\r\n\r\n- [segmentation-models-pytorch](https:\u002F\u002Fgithub.com\u002Fqubvel\u002Fsegmentation-models.pytorch)\r\n- [EfficientNet](https:\u002F\u002Farxiv.org\u002Fabs\u002F1905.11946)\r\n- [UNet++](https:\u002F\u002Farxiv.org\u002Fabs\u002F1912.05074)\r\n- [Lovasz Loss](https:\u002F\u002Fgithub.com\u002Fbermanmaxim\u002FLovaszSoftmax)\r\n","该项目是一个高精度的眼底图像分割模型，基于UNet++架构，实现了多类视网膜图像分割。其核心功能包括背景、视网膜区域及有效反射的识别，验证集Dice系数达到0.9554，支持四方向测试时增强（TTA）以提高预测鲁棒性，并提供预训练模型供快速部署使用。技术上采用EfficientNet-B4作为编码器，结合Focal Loss、Dice Loss和Lovasz Loss进行联合训练。适合眼科医学影像分析领域，如眼底病变检测与诊断等应用场景。",2,"2026-06-11 03:31:34","CREATED_QUERY"]