Modification of convolutional neural net "UNET" for image segmentation in Keras framework

Overview

ZF_UNET_224 Pretrained Model

Modification of convolutional neural net "UNET" for image segmentation in Keras framework

Requirements

Python 3.*, Keras 2.1, Tensorflow 1.4

Usage

from zf_unet_224_model import ZF_UNET_224, dice_coef_loss, dice_coef
from keras.optimizers import Adam

model = ZF_UNET_224(weights='generator')
optim = Adam()
model.compile(optimizer=optim, loss=dice_coef_loss, metrics=[dice_coef])

model.fit(...)

Notes

Pretrained weights

Download: Weights for Tensorflow backend ~123 MB (Keras 2.1, Dice coef: 0.998)

Weights were obtained with random image generator (generator code available here: train_infinite_generator.py). See example of images from generator below.

Example of images from generator

Dice coefficient for pretrained weights: ~0.998. See history of learning below:

Log of dice coefficient during training process

Comments
  • Extended example

    Extended example

    Hi, I have created extended example based on your repository: https://github.com/mrgloom/keras-semantic-segmentation-example

    It also use random colors for foreground and background (not like lighter and darker like here https://github.com/ZFTurbo/ZF_UNET_224_Pretrained_Model/blob/master/train_infinite_generator.py#L24 ), one idea behind it is that in that case network can learn 'shape of object' not just 'thresholding and separating background and foreground', also looks like using random colors make problem harder and network converges slower.

    Also I have experienced some problems:

    1. Netwoks not always converges on second run with fixed params even for this toy problem, looks like it depens on random seed.
    2. Dice loss and jaccard loss are harder to train than binary crossentropy, any ideas why? Network architecture is the same just loss differs, I even tried to load trained weights from binary crossentropy loss network and use them in dice loss network which show high dice coef.
    opened by mrgloom 8
  • Deeper network

    Deeper network

    I know this is not an issue, but I wanted to contact you to know how did you make the network deeper in keras for the DSTL competition using this model?

    opened by nassarofficial 6
  • Tensorflow problem

    Tensorflow problem

    When I use tensorflow-1.3.0 as backend, I get this kind of error:

    builtins.ValueError: Dimension 2 in both shapes must be equal, but are 3 and 32 for 'Assign' (op: 'Assign') with input shapes: [3,3,3,32], [3,3,32,3].
    
    opened by lawlite19 5
  • preprocess_batch for real data

    preprocess_batch for real data

    Here is preprocessing for the batch (looks like 256 should be 255 ;) ) https://github.com/ZFTurbo/ZF_UNET_224_Pretrained_Model/blob/master/zf_unet_224_model.py#L27

    Is it ok for real images to use code like this or it should be calculated for entire dataset?

    batch=batch-np.mean(batch)
    batch=batch/np.std(batch)
    

    Also how crucial is impact of data normalization for U-net? In my tests even on this simple synthetic data network doesn't converges if input is not normalized.

    opened by mrgloom 2
  • Applying pretrained weights to 128*128 size image

    Applying pretrained weights to 128*128 size image

    You have generated pretrained weights for 224224 input size, but I have 128128. How can we use such weights in this situation, but without padding/upsampling 128*128 images. Sorry for silly question - is it worth trying in kaggle salt competition?

    opened by Diyago 1
  • Attribute Error

    Attribute Error

    Traceback (most recent call last): File "train.py", line 11, in import segmentation_models as sm File "/home/melih/anaconda3/envs/ai/lib/python3.6/site-packages/segmentation_models/init.py", line 98, in set_framework(_framework) File "/home/melih/anaconda3/envs/ai/lib/python3.6/site-packages/segmentation_models/init.py", line 68, in set_framework import efficientnet.keras # init custom objects File "/home/melih/anaconda3/envs/ai/lib/python3.6/site-packages/efficientnet/keras.py", line 17, in init_keras_custom_objects() File "/home/melih/anaconda3/envs/ai/lib/python3.6/site-packages/efficientnet/init.py", line 71, in init_keras_custom_objects keras.utils.generic_utils.get_custom_objects().update(custom_objects) AttributeError: module 'keras.utils' has no attribute 'generic_utils'

    when I run the code, I got the result below but don't know why there is no generic_utils attribute in the library since there is in the keras.

    opened by melih1996 0
  • How to run the model for 6 input channels?

    How to run the model for 6 input channels?

    Is it possible to run the model for 6 input channels? Three inputs in that are RGB values and the other three are metrics I want to pass on into the architecture for my use case.

    opened by ShreyaPandita01 2
  • dice and jaccard metrics

    dice and jaccard metrics

    Thanks for the repo. I am wondering why do you use a smoothing factor of 1.0 in both dice and jaccard coefficients? Where does this value comes from? And what about using another smaller value close to zero, e.g. K.epsilon()

    opened by tinalegre 3
  • model.fit step

    model.fit step

    Hi! I would like to know how I should perform the model.fit instruction. model.fit(trainSet, mask_trainSet, batch_size=20, nb_epoch=1, verbose=1,validation_split=0.2, shuffle=True, callbacks=[model_checkpoint])¿? What I write in callback??

    And how should I use the weights if I wan't to use pretained weights??

    Thank you very much and sorry for the inconvenience!

    opened by AmericaBG 7
  • How to generate img and mask correctly

    How to generate img and mask correctly

    I run your code and then find that the img batch has a shape(16,224,224,3),but mask batch has a shape(16,1,224,224). I don't understand it.Can you explain it to me?I use my dataset to train unet and then the dice coef is high,but the real effect is bad.

    opened by wong-way 6
Releases(v1.0)
Implementation of ReSeg using PyTorch

Implementation of ReSeg using PyTorch ReSeg: A Recurrent Neural Network-based Model for Semantic Segmentation Pascal-Part Annotations Pascal VOC 2010

Onur Kaplan 46 Nov 23, 2022
CFNet: Cascade and Fused Cost Volume for Robust Stereo Matching(CVPR2021)

CFNet(CVPR 2021) This is the implementation of the paper CFNet: Cascade and Fused Cost Volume for Robust Stereo Matching, CVPR 2021, Zhelun Shen, Yuch

106 Dec 28, 2022
Open source hardware and software platform to build a small scale self driving car.

Donkeycar is minimalist and modular self driving library for Python. It is developed for hobbyists and students with a focus on allowing fast experimentation and easy community contributions.

Autorope 2.4k Jan 04, 2023
Background-Click Supervision for Temporal Action Localization

Background-Click Supervision for Temporal Action Localization This repository is the official implementation of BackTAL. In this work, we study the te

LeYang 221 Oct 09, 2022
PyTorch Implementation of the paper Learning to Reweight Examples for Robust Deep Learning

Learning to Reweight Examples for Robust Deep Learning Unofficial PyTorch implementation of Learning to Reweight Examples for Robust Deep Learning. Th

Daniel Stanley Tan 325 Dec 28, 2022
Fast and customizable reconnaissance workflow tool based on simple YAML based DSL.

Fast and customizable reconnaissance workflow tool based on simple YAML based DSL, with support of notifications and distributed workload of that work

Américo Júnior 3 Mar 11, 2022
Real-time LIDAR-based Urban Road and Sidewalk detection for Autonomous Vehicles 🚗

urban_road_filter: a real-time LIDAR-based urban road and sidewalk detection algorithm for autonomous vehicles Dependency ROS (tested with Kinetic and

JKK - Vehicle Industry Research Center 180 Dec 12, 2022
Official PyTorch implemention of our paper "Learning to Rectify for Robust Learning with Noisy Labels".

WarPI The official PyTorch implemention of our paper "Learning to Rectify for Robust Learning with Noisy Labels". Run python main.py --corruption_type

Haoliang Sun 3 Sep 03, 2022
An Api for Emotion recognition.

PLAYEMO Playemo was built from the ground-up with Flask, a python tool that makes it easy for developers to build APIs. Use Cases Is Python your langu

greek geek 2 Jul 16, 2022
Viewmaker Networks: Learning Views for Unsupervised Representation Learning

Viewmaker Networks: Learning Views for Unsupervised Representation Learning Alex Tamkin, Mike Wu, and Noah Goodman Paper link: https://arxiv.org/abs/2

Alex Tamkin 31 Dec 01, 2022
Text2Art is an AI art generator powered with VQGAN + CLIP and CLIPDrawer models

Text2Art is an AI art generator powered with VQGAN + CLIP and CLIPDrawer models. You can easily generate all kind of art from drawing, painting, sketch, or even a specific artist style just using a t

Muhammad Fathy Rashad 643 Dec 30, 2022
Implementation for Panoptic-PolarNet (CVPR 2021)

Panoptic-PolarNet This is the official implementation of Panoptic-PolarNet. [ArXiv paper] Introduction Panoptic-PolarNet is a fast and robust LiDAR po

Zixiang Zhou 126 Jan 01, 2023
Scalable Optical Flow-based Image Montaging and Alignment

SOFIMA SOFIMA (Scalable Optical Flow-based Image Montaging and Alignment) is a tool for stitching, aligning and warping large 2d, 3d and 4d microscopy

Google Research 16 Dec 21, 2022
Official implementation for “Unsupervised Low-Light Image Enhancement via Histogram Equalization Prior”

Unsupervised Low-Light Image Enhancement via Histogram Equalization Prior. The code will release soon. Implementation Python3 PyTorch=1.0 NVIDIA GPU+

FengZhang 34 Dec 04, 2022
PyTorch Code for "Generalization in Dexterous Manipulation via Geometry-Aware Multi-Task Learning"

Generalization in Dexterous Manipulation via Geometry-Aware Multi-Task Learning [Project Page] [Paper] Wenlong Huang1, Igor Mordatch2, Pieter Abbeel1,

Wenlong Huang 40 Nov 22, 2022
Fully convolutional networks for semantic segmentation

FCN-semantic-segmentation Simple end-to-end semantic segmentation using fully convolutional networks [1]. Takes a pretrained 34-layer ResNet [2], remo

Kai Arulkumaran 186 Dec 25, 2022
On Size-Oriented Long-Tailed Graph Classification of Graph Neural Networks

On Size-Oriented Long-Tailed Graph Classification of Graph Neural Networks We provide the code (in PyTorch) and datasets for our paper "On Size-Orient

Zemin Liu 4 Jun 18, 2022
CvT-ASSD: Convolutional vision-Transformerbased Attentive Single Shot MultiBox Detector (ICTAI 2021 CCF-C 会议)The 33rd IEEE International Conference on Tools with Artificial Intelligence

CvT-ASSD including extra CvT, CvT-SSD, VGG-ASSD models original-code-website: https://github.com/albert-jin/CvT-SSD new-code-website: https://github.c

金伟强 -上海大学人工智能小渣渣~ 5 Mar 07, 2022
Maximum Spatial Perturbation for Image-to-Image Translation (Official Implementation)

MSPC for I2I This repository is by Yanwu Xu and contains the PyTorch source code to reproduce the experiments in our CVPR2022 paper Maximum Spatial Pe

51 Dec 14, 2022
As-ViT: Auto-scaling Vision Transformers without Training

As-ViT: Auto-scaling Vision Transformers without Training [PDF] Wuyang Chen, Wei Huang, Xianzhi Du, Xiaodan Song, Zhangyang Wang, Denny Zhou In ICLR 2

VITA 68 Sep 05, 2022