Complete U-net Implementation with keras

Overview

U Net Lowered with Keras

Complete U-net Implementation with keras






Original Paper Link : https://arxiv.org/abs/1505.04597

Special Implementations :


The model is implemented using the original paper. But I have changed the number of filters of the layers. The implemented number of layers are reduced to 25% of the original paper.

Original Model Architecture :

Dataset :


The dataset has been taken from kaggle . It had a specific directory tree, but it was tough to execute dataset building from it, so I prepared an usable dat directory.

Link : https://www.kaggle.com/azkihimmawan/chest-xray-masks-and-defect-detection

Primary Directory Tree :

.
└── root/
    ├── train_images/
    │   └── id/
    │       ├── images/
    │       │   └── id.png
    │       └── masks/
    │           └── id.png
    └── test_images/
        └── id/
            └── id.png

Given Images :

Image Mask

Supporting Libraries :

Numpy opencv Matplotlib

Library Versions :

All versions are up to date as per 14th June 2021.

Dataset Directory Generation :


We have performed operations to ceate the data directory like this :

              .
              └── root/
                  ├── train/
                  │   ├── images/
                  │   │   └── id.png
                  │   └── masks/
                  │       └── id.png
                  └── test/
                      └── id.png

Model Architecture ( U-Net Lowered ):

Model: “UNet-Lowered”

Layer Type Output Shape Param Connected to
input_1 (InputLayer) [(None, 512, 512, 1) 0
conv2d (Conv2D) (None, 512, 512, 16) 160 input_1[0][0]
conv2d_1 (Conv2D) (None, 512, 512, 16) 2320 conv2d[0][0]
max_pooling2d (MaxPooling2D) (None, 256, 256, 16) 0 conv2d_1[0][0]
conv2d_2 (Conv2D) (None, 256, 256, 32) 4640 max_pooling2d[0][0]
conv2d_3 (Conv2D) (None, 256, 256, 32) 9248 conv2d_2[0][0]
max_pooling2d_1 (MaxPooling2D) (None, 128, 128, 32) 0 conv2d_3[0][0]
conv2d_4 (Conv2D) (None, 128, 128, 64) 18496 max_pooling2d_1[0][0]
conv2d_5 (Conv2D) (None, 128, 128, 64) 36928 conv2d_4[0][0]
max_pooling2d_2 (MaxPooling2D) (None, 64, 64, 64) 0 conv2d_5[0][0]
conv2d_6 (Conv2D) (None, 64, 64, 128) 73856 max_pooling2d_2[0][0]
conv2d_7 (Conv2D) (None, 64, 64, 128) 147584 conv2d_6[0][0]
dropout (Dropout) (None, 64, 64, 128) 0 conv2d_7[0][0]
max_pooling2d_3 (MaxPooling2D) (None, 32, 32, 128) 0 dropout[0][0]
conv2d_8 (Conv2D) (None, 32, 32, 256) 295168 max_pooling2d_3[0][0]
conv2d_9 (Conv2D) (None, 32, 32, 256) 590080 conv2d_8[0][0]
dropout_1 (Dropout) (None, 32, 32, 256) 0 conv2d_9[0][0]
up_sampling2d (UpSampling2D) (None, 64, 64, 256) 0 dropout_1[0][0]
conv2d_10 (Conv2D) (None, 64, 64, 128) 131200 up_sampling2d[0][0]
concatenate (Concatenate) (None, 64, 64, 256) 0 dropout[0][0] & conv2d_10[0][0]
conv2d_11 (Conv2D) (None, 64, 64, 128) 295040 concatenate[0][0]
conv2d_12 (Conv2D) (None, 64, 64, 128) 147584
up_sampling2d_1 (UpSampling2D) (None, 128, 128, 128) 0 conv2d_12[0][0]
conv2d_13 (Conv2D) (None, 128, 128, 64) 32832 up_sampling2d_1[0][0]
concatenate_1 (Concatenate) (None, 128, 128, 128) 0 conv2d_5[0][0] & conv2d_13[0][0]
conv2d_14 (Conv2D) (None, 128, 128, 64) 73792 concatenate_1[0][0]
conv2d_15 (Conv2D) (None, 128, 128, 64) 36928 conv2d_14[0][0]
up_sampling2d_2 (UpSampling2D) (None, 256, 256, 64) 0 conv2d_15[0][0]
conv2d_16 (Conv2D) (None, 256, 256, 32) 8224 up_sampling2d_2[0][0]
concatenate_2 (Concatenate) (None, 256, 256, 64) 0 conv2d_3[0][0] & conv2d_16[0][0]
conv2d_17 (Conv2D) (None, 256, 256, 32) 18464 concatenate_2[0][0]
conv2d_18 (Conv2D) (None, 256, 256, 32) 9248 conv2d_17[0][0]
up_sampling2d_3 (UpSampling2D) (None, 512, 512, 32) 0 conv2d_18[0][0]
conv2d_19 (Conv2D) (None, 512, 512, 16) 2064 up_sampling2d_3[0][0]
concatenate_3 (Concatenate) (None, 512, 512, 32) 0 conv2d_1[0][0] & conv2d_19[0][0]
conv2d_20 (Conv2D) (None, 512, 512, 16) 4624 concatenate_3[0][0]
conv2d_21 (Conv2D) (None, 512, 512, 16) 2320 conv2d_20[0][0]
conv2d_22 (Conv2D) (None, 512, 512, 2) 290 conv2d_21[0][0]
conv2d_23 (Conv2D) (None, 512, 512, 1) 3 conv2d_22[0][0]

Data Preparation :

Taken single channels of both image and mask for training.

Hyperparameters :

      Image Shape : (512 , 512 , 1)
      Optimizer : Adam ( Learning Rate : 1e-4 )
      Loss : Binary Cross Entropy 
      Metrics : Accuracy
      Epochs on Training : 100
      Train Validation Ratio : ( 85%-15% )
      Batch Size : 10

Model Evaluation Metrics :

Model Performance on Train Data :

Model Performance on Validation Data :

One task left : Will update the tutorial notebooks soon ;)

Conclusion :

The full model on the simpliefied 1 channel images was giving bad overfitted accuracy. But this structure shows better and efficient tuning over the data.

STAR the repository if this was helpful :) Also follow me on kaggle and Linkedin.

THANK YOU for visiting :)

Owner
Sagnik Roy
Kaggle Expert exploring Computer Vision as no one did!
Sagnik Roy
This is the code of "Multi-view Contrastive Graph Clustering" in NeurlPS 2021.

MCGC Description This is the code of "Multi-view Contrastive Graph Clustering" in NeurlPS 2021. Datasets Results ACM DBLP IMDB Amazon photos Amazon co

31 Nov 14, 2022
Pytorch implementation of the paper Improving Text-to-Image Synthesis Using Contrastive Learning

T2I_CL This is the official Pytorch implementation of the paper Improving Text-to-Image Synthesis Using Contrastive Learning Requirements Linux Python

42 Dec 31, 2022
Light-SERNet: A lightweight fully convolutional neural network for speech emotion recognition

Light-SERNet This is the Tensorflow 2.x implementation of our paper "Light-SERNet: A lightweight fully convolutional neural network for speech emotion

Arya Aftab 29 Nov 12, 2022
Few-shot Neural Architecture Search

One-shot Neural Architecture Search uses a single supernet to approximate the performance each architecture. However, this performance estimation is super inaccurate because of co-adaption among oper

Yiyang Zhao 38 Oct 18, 2022
Differentiable scientific computing library

xitorch: differentiable scientific computing library xitorch is a PyTorch-based library of differentiable functions and functionals that can be widely

98 Dec 26, 2022
Improving Non-autoregressive Generation with Mixup Training

MIST Training MIST TRAIN_FILE=/your/path/to/train.json VALID_FILE=/your/path/to/valid.json OUTPUT_DIR=/your/path/to/save_checkpoints CACHE_DIR=/your/p

7 Nov 22, 2022
Code for ICDM2020 full paper: "Sub-graph Contrast for Scalable Self-Supervised Graph Representation Learning"

Subg-Con Sub-graph Contrast for Scalable Self-Supervised Graph Representation Learning (Jiao et al., ICDM 2020): https://arxiv.org/abs/2009.10273 Over

34 Jul 06, 2022
Unimodal Face Classification with Multimodal Training

Unimodal Face Classification with Multimodal Training This is a PyTorch implementation of the following paper: Unimodal Face Classification with Multi

Wenbin Teng 3 Jul 06, 2022
Make a Turtlebot3 follow a figure 8 trajectory and create a robot arm and make it follow a trajectory

HW2 - ME 495 Overview Part 1: Makes the robot move in a figure 8 shape. The robot starts moving when launched on a real turtlebot3 and can be paused a

Devesh Bhura 0 Oct 21, 2022
Based on Stockfish neural network(similar to LcZero)

MarcoEngine Marco Engine - interesnaya neyronnaya shakhmatnaya set', kotoraya ispol'zuyet metod samoobucheniya(dostizheniye khoroshoy igy putem proboy

Marcus Kemaul 4 Mar 12, 2022
Dictionary Learning with Uniform Sparse Representations for Anomaly Detection

Dictionary Learning with Uniform Sparse Representations for Anomaly Detection Implementation of the Uniform DL Representation for AD algorithm describ

Paul Irofti 1 Nov 23, 2022
Permute Me Softly: Learning Soft Permutations for Graph Representations

Permute Me Softly: Learning Soft Permutations for Graph Representations

Giannis Nikolentzos 7 Jul 10, 2022
A python library to build Model Trees with Linear Models at the leaves.

A python library to build Model Trees with Linear Models at the leaves.

Marco Cerliani 212 Dec 30, 2022
Codes for CyGen, the novel generative modeling framework proposed in "On the Generative Utility of Cyclic Conditionals" (NeurIPS-21)

On the Generative Utility of Cyclic Conditionals This repository is the official implementation of "On the Generative Utility of Cyclic Conditionals"

Chang Liu 44 Nov 16, 2022
The world's largest toxicity dataset.

The Toxicity Dataset by Surge AI Saving the internet is fun. Combing through thousands of online comments to build a toxicity dataset isn't. That's wh

Surge AI 134 Dec 19, 2022
SenseNet is a sensorimotor and touch simulator for deep reinforcement learning research

SenseNet is a sensorimotor and touch simulator for deep reinforcement learning research

59 Feb 25, 2022
Yolov3 pytorch implementation

YOLOV3 Pytorch实现 在bubbliiing大佬代码的基础上进行了修改,添加了部分注释。 预训练模型 预训练模型来源于bubbliiing。 链接:https://pan.baidu.com/s/1ncREw6Na9ycZptdxiVMApw 提取码:appk 训练自己的数据集 按照VO

4 Aug 27, 2022
This repository contains all the code and materials distributed in the 2021 Q-Programming Summer of Qode.

Q-Programming Summer of Qode This repository contains all the code and materials distributed in the Q-Programming Summer of Qode. If you want to creat

Sammarth Kumar 11 Jun 11, 2021
Multi-objective constrained optimization for energy applications via tree ensembles

Multi-objective constrained optimization for energy applications via tree ensembles

C⚙G - Imperial College London 1 Nov 19, 2021