How zhixuhao/unet works
Project type and purpose
• This is a research‐oriented deep-learning image segmentation project implementing the U-Net architecture in Keras.
• It ingests a biomedical microscopy dataset (“membrane”) and trains a convolutional network to produce pixel-wise segmentation masks.
File structure
Top-level files and folders reveal the main components:
• data/ ← raw and pre-processed images (train, test, labels, augmented)
• data.py ← Python module for loading and augmenting data
• dataPrepare.ipynb ← notebook that explores and preprocesses the data, generates augmentations
• model.py ← U-Net model definition using Keras functional API
• trainUnet.ipynb ← interactive training notebook
• main.py ← CLI entry point for running inference on test images
• README.md, LICENSE ← documentation and licensing
Extract key architecture details from README
• Data augmentation via Keras’s ImageDataGenerator
• Model: U-Net with encoder/decoder paths, skip connections, sigmoid output for mask prediction
• Training: binary crossentropy loss, five epochs, using TensorFlow backend
• Inference: main.py applies the trained model to test images and writes segmentation masks
a. Main components:
1. Raw Data Storage (data/membrane)
2. Data Preparation & Augmentation Module (data.py + dataPrepare.ipynb)
3. Model Definition (model.py)
4. Training Engine (trainUnet.ipynb + Keras/TensorFlow)
5. Inference Engine (main.py + Keras/TensorFlow)
6. Output Storage & Visualization (img/, output folder)
7. External Libraries (Keras, TensorFlow, Python)
b. Data flow / interactions:
• Raw images → Data Preparation & Augmentation → Augmented dataset
• Augmented dataset + model definition → Training Engine → Trained model artifacts
• Trained model + test images → Inference Engine → Segmentation masks → Output Storage/Visualization
c. Architectural patterns/design principles:
• Modular separation: I/O & preprocessing (data.py & notebooks), model architecture (model.py), training vs. inference logic (trainUnet.ipynb vs. main.py)
• Reproducibility via notebooks and a single CLI entry point
• Functional API in Keras enforces clear graph of layers (the U-Net)
d. Key technologies/frameworks:
• Python 2.7–3.5
• Keras (>=1.0) on TensorFlow backend
• Jupyter notebooks for interactive exploration and training
• ImageDataGenerator for on-the-fly augmentation
Elements
• Clear labels: “Raw Data”, “Augmentor”, “U-Net Model”, “Trainer”, “Inferencer”, “Outputs”
– Rectangles for modules (data, preprocessing, model)
– Hexagons or clouds for external dependencies (Keras, TensorFlow)