# zhixuhao/unet: a Keras U-Net for the ISBI membrane segmentation dataset

> A small, readable Keras implementation of U-Net trained on 30 electron microscopy images. It is a teaching repository, not a production segmentation library, and its dependency pins decide whether it runs at all today.

**zhixuhao/unet** — unet for image segmentation

- Repository: https://github.com/zhixuhao/unet
- Stars: 4,941 · Forks: 2,001
- Language: Jupyter Notebook
- License: MIT
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/zhixuhao-unet

## What zhixuhao/unet actually is

The repository is a from-scratch implementation of the U-Net architecture in Keras, written against the ISBI cell membrane segmentation challenge. The README states the architecture was inspired by the original U-Net paper, and the author downloaded and pre-processed that dataset, which ships inside the repo under data/membrane. So the project solves one narrow problem: giving you a complete, runnable U-Net example with data already attached, so you can see the full path from raw 512x512 images to a predicted mask without hunting for a dataset first.

It is for people learning segmentation or prototyping an idea quickly. The README frames the whole thing as a tutorial: dependencies, run main.py, or follow trainUnet. There is no package on PyPI, no CLI, no configuration file, and no inference server. You clone it, you read it, you run it. That framing matters because it sets the correct expectation. This is closer to a lab notebook than to a tool you would import into another codebase.

## The data path: 30 images, ImageDataGenerator, and a 512x512 mask

The training set is tiny. The README says the data for training contains 30 images at 512x512, and explicitly calls that far from enough to feed a deep neural network. The response is data augmentation through ImageDataGenerator in keras.preprocessing.image, with dataPrepare.ipynb and data.py handling the preparation. That is the whole data pipeline: a small folder of images, an augmentation generator, and a batch flow into the model.

The output side is equally simple. The network emits a 512x512 mask, and a sigmoid activation keeps every pixel in [0, 1], which makes the training objective a per-pixel binary decision. Loss is binary crossentropy, as the README states. Training runs for 5 epochs and the README reports accuracy around 0.97 after those 5 epochs.

That number deserves a caveat the README does not give. Pixel accuracy on a membrane segmentation task is a weak signal, because the foreground and background are heavily imbalanced, and a model that predicts mostly background can still score well. The README does not report IoU, Dice, or any class-balanced metric, and it does not describe a validation split. If you intend to judge this model rather than read it, treat 0.97 as a starting point to reproduce, not as a quality claim.

## Installing and running a first segmentation

There is no install step in the README, because there is nothing to install from a package index. You get the code by cloning the repository, then satisfy the two dependencies the README lists, Tensorflow and Keras >= 1.0. The README also states the code should be compatible with Python versions 2.7 through 3.5, which is the single most important constraint on this repository.

```bash
git clone https://github.com/zhixuhao/unet
cd unet
pip install tensorflow
pip install "keras>=1.0"
```

Be deliberate here. Those two pip commands will resolve to current releases in a fresh environment, and current Keras is not the Keras this code was written against. The README's own compatibility note points at Python 2.7-3.5, so a modern Python will likely fail before you ever reach the model. A virtual environment you control is the safer place to try it.

Once the environment is settled, the README gives two entry points. The first is main.py:

```bash
python main.py
```

The README says you will see the predicted results of the test image in data/membrane/test. The second is the notebook trainUnet.ipynb, which walks through training rather than inference. The repository layout supports both: model.py holds the network, data.py holds loading and augmentation, and the two notebooks cover preparation and training. Start with main.py if you want to see output immediately; open trainUnet.ipynb if you want to see how the 5-epoch training loop is assembled.

## Where this repository stops being the right tool

The dependency story is the main limitation, and it is not a small one. Keras >= 1.0 as written in 2018 is a different library surface from what pip installs today: the standalone Keras package was folded into TensorFlow, and the preprocessing module path the README references has moved. The README lists Tensorflow without a version pin at all. So the honest description is that this code targets an environment from the Python 2.7-3.5 era, and running it on a current stack requires you to either pin old versions or port the model definition yourself.

Second, the scope is binary segmentation on one dataset. The sigmoid output and binary crossentropy loss mean the model as written produces one foreground mask. If you need multi-class segmentation, you are changing the final activation, the loss, and the label handling, at which point you are writing a new project and only borrowing the encoder-decoder shape.

Third, there is no evaluation harness. No metric beyond the reported accuracy, no validation split documented in the README, no checkpointing described, no way to compare two runs. For a tutorial that is fine. For anything you intend to trust, it is not. And the repository carries no releases, so there is no version to pin against when you come back to it in a year.

## How it compares to the PyTorch U-Net implementations

The obvious alternative people search for alongside this repository is a PyTorch U-Net, and the difference is not just the framework. The PyTorch implementations in wide use, including the well-known PyTorch-UNet, are typically structured as a reusable model class plus a training script with configurable data paths, metric logging, and checkpoint saving. You point them at your own dataset and they keep working across framework versions because they are maintained.

zhixuhao/unet takes the opposite approach. It is Keras, it is one dataset, and it is deliberately small enough to read end to end in an afternoon. The model.py file is short enough that the architecture is legible without documentation. That is the trade: you get clarity and a bundled dataset, and you give up version currency, configurability, and any evaluation machinery.

If your goal is to understand how the contracting and expanding paths connect, this repository is a good place to look. If your goal is to segment your own images next month on a current stack, a maintained PyTorch implementation will cost you less time, even accounting for learning a new API.

## Maintenance, licensing, and what upgrading costs

The repository is not archived, and the last push was on 2026-03-27. That is recent enough that the project has not been abandoned, but the README content still describes Keras >= 1.0 and Python 2.7-3.5, so a recent push should not be read as a modernisation of the code. There are no releases listed, which means there is no tagged version to depend on and no changelog to consult before you pull. If you vendor this code, record the commit you took, because master is the only thing moving.

The licence is MIT, which is permissive and places few obligations on reuse beyond preserving the copyright and licence notice. That applies to the code in the repository. The dataset is a separate question: the README states the data comes from the ISBI challenge and that the author downloaded and pre-processed it. The README does not restate the terms of that challenge data, so if you plan to redistribute the images or use them commercially, check the original challenge terms rather than assuming the MIT licence covers the data folder. This is a factual gap, not legal advice.

The upgrade cost is the real budget item. Porting model.py to current Keras means replacing the old layer and preprocessing imports, and re-verifying that the augmentation still produces the same batches. That is a bounded task for someone comfortable with Keras, and an open-ended one for someone who is not.

## Conclusion

Adopt zhixuhao/unet if you want to read a short Keras functional-API U-Net and run it against the bundled membrane data, and treat it as a teaching artifact rather than a library. Do not adopt it if you need current TensorFlow/Keras compatibility, multi-class segmentation, or a maintained training pipeline; the README pins Keras >= 1.0 and Python 2.7-3.5, and the last push was on 2026-03-27. Before running anything, open model.py to confirm the layer API it uses, and check whether data/membrane still contains the 30 training images the README describes.

## FAQ

### What exactly is U-Net in the zhixuhao/unet repository?

It is a convolutional network for image segmentation, implemented here with the Keras functional API, whose output is a 512x512 mask with sigmoid activation keeping pixels in the [0, 1] range. The README states the architecture was inspired by the U-Net paper on biomedical image segmentation.

### What is the best model for image segmentation?

The repository does not compare models and does not make a claim about which is best. It presents one U-Net implementation trained on the ISBI membrane data, reporting about 0.97 accuracy after 5 epochs, which is a result for that dataset rather than a ranking.

### Why is U-Net so good?

The README does not argue for the architecture's merits beyond noting it was inspired by the original U-Net paper. What the repository shows concretely is a network that takes 512x512 input and produces a same-size mask, with sigmoid activation bounding each pixel to [0, 1].

### What are the key differences between U-Net and UNet++?

The repository does not mention UNet++ and offers no comparison, so this cannot be answered from its contents. It documents only a single U-Net built with the Keras functional API.

## Sources

- [Issues](https://github.com/zhixuhao/unet/issues)
- [License: MIT](https://github.com/zhixuhao/unet/blob/master/LICENSE)
- [README](https://github.com/zhixuhao/unet/blob/master/README.md)
- [zhixuhao/unet on GitHub](https://github.com/zhixuhao/unet)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/zhixuhao-unet
