Code Monkey home page Code Monkey logo

u-net-pytorch's Introduction

An implementation of U-Net based on PyTorch

U-Net is a convolutional neural network architecture, originally developed for biomedical image segmentation. It features a symmetric, U-shaped structure with a contracting path to capture context and a symmetric expanding path for precise localization, enabling it to effectively segment images even with limited training data. U-Net is widely used in medical image analysis and other segmentation tasks.

arXiv

U-Net architecture in the original paper:

U-Net

Getting Started with Your Project

.
├── LICENSE
├── README.md
├── config.yaml
├── data.py
├── model
│   ├── Trainer.py
│   └── UNet.py
├── model-params
├── requirements.txt
├── result
└── train_model.py
  1. Install Dependencies

    Begin by installing the required packages using pip

    pip install -r requirements.txt
  2. Configure Your Model

    Next, tailor the config.yaml file to your specific requirements

    model-conf:
      num_classes: 2 # Define the number of classes
    
    train-conf:
      w_c: True # Include class frequency in the loss function pixel weight
      w_d: False # Include pixel border distance in the loss function pixel weight (TODO)
      num_epochs: 20 # Set the number of training epochs
      batch_size: 8 # Specify the batch size
      lr: 0.0001 # Set the learning rate
  3. Prepare Your Dataset

    In data.py, complete the dataset preparation stage:

    def load_train_dataset():
        print('Loading training dataset...')
        # TODO
        return []
    
    def load_val_dataset():
        print('Loading validation dataset...')
        # TODO
        return []
    
    def load_test_dataset():
        print("Loading test dataset...")
        # TODO
        return []

    Ensure that each function returns a list of tuples (img, mask). In this context, img should be a three-channel tensor, for instance, (3, 512, 512), and mask should be a one-channel integer tensor, such as (512, 512). The dimensions of mask must correspond to those of img, with both the height and width being divisible by 32. Each element within mask represents the class of the pixel it corresponds to, ranging from 0 to num_classes - 1.

  4. Initiate Training

    Start the training process with the following command:

    python train_model.py

    Training

    Upon completion, the training and MIoU curves will be saved in the result directory. The model parameters for each epoch are stored in model-params as .pth files.

This revised version maintains the original technical accuracy while enhancing clarity and formality.

Todo List

  • Complete w_d generation task

  • Complete road segmentation experiment

  • Complete object segmentation experiment on VOC2012 dataset

u-net-pytorch's People

Contributors

goer17 avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.