Keras implementation of Real-Time Semantic Segmentation on High-Resolution Images

Overview

Keras-ICNet

[paper]

Keras implementation of Real-Time Semantic Segmentation on High-Resolution Images. Training in progress!

Requisites

  • Python 3.6.3
  • Keras 2.1.1 with Tensorflow backend
  • A dataset, such as Cityscapes or Mapillary (Mapillary was used in this case).

Train

Issue ./train --help for options to start a training session, default arguments should work out-of-the-box.

You need to place the dataset following the next directory convention:

.
├── mapillary                   
|   ├── training
|   |   ├── images             # Contains the input images
|   |   └── instances          # Contains the target labels
|   ├── validation
|   |   ├── images
|   |   └── instances
|   └── testing
|   |   └── images

These are the results of training for 300 epochs ./train --epochs 300

Training

conv6_cls_categorical_accuracy conv6_cls_loss loss

Validation

val_conv6_cls_categorical_accuracy val_conv6_cls_loss val_loss

Test

Issue ./test --help for options to start a testing session, default arguments should work out-of-the-box.

Output examples

10 07

TODO

  • Perform class weighting
Comments
  • [ERROR] StopIteration: index 117 is out of bounds for axis 1 with size 66

    [ERROR] StopIteration: index 117 is out of bounds for axis 1 with size 66

    Hi, I tried to run the model but I get the following error

    Epoch 1/100 Traceback (most recent call last): File "/home/user/.local/lib/python3.5/site-packages/keras/utils/data_utils.py", line 578, in get inputs = self.queue.get(block=True).get() File "/usr/lib/python3.5/multiprocessing/pool.py", line 608, in get raise self._value File "/usr/lib/python3.5/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/home/user/.local/lib/python3.5/site-packages/keras/utils/data_utils.py", line 401, in get_index return _SHARED_SEQUENCES[uid][i] File "/home/user/Desktop/Keras-ICNet/utils.py", line 95, in getitem self.Y1[n] = to_categorical(cv2.resize(label, (label.shape[1]//4, label.shape[0]//4)), self.n_classes).reshape((label.shape[0]//4, label.shape[1]//4, -1))
    File "/home/user/.local/lib/python3.5/site-packages/keras/utils/np_utils.py", line 31, in to_categorical categorical[np.arange(n), y] = 1 IndexError: index 117 is out of bounds for axis 1 with size 66

    The above exception was the direct cause of the following exception:

    Traceback`(most recent call last): File "train", line 63, in use_multiprocessing=False, shuffle=True, max_queue_size=10, initial_epoch=opt.epoch)
    File "/home/user/.local/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/home/user/.local/lib/python3.5/site-packages/keras/engine/training.py", line 2192, in fit_generator generator_output = next(output_generator) File "/home/user/.local/lib/python3.5/site-packages/keras/utils/data_utils.py", line 584, in get six.raise_from(StopIteration(e), e) File "", line 3, in raise_from StopIteration: index 117 is out of bounds for axis 1 with size 66

    Any ideas ?

    Many thanks

    opened by MathiasGilson 3
  • Ok that's my bad, the keras implementation is very fast too !

    Ok that's my bad, the keras implementation is very fast too !

    Ok that's my bad, the keras implementation is very fast too ! I ran it on 20 images on a single batch and as you can see it goes from 1 FPS to 90 FPS after only one prediction !

    [GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7335]

    Generated segmentations in 0.879213809967041 seconds -- 1.1373797689068224 FPS Generated segmentations in 0.011792182922363281 seconds -- 84.80194096239386 FPS Generated segmentations in 0.011512994766235352 seconds -- 86.85837354262875 FPS Generated segmentations in 0.01149892807006836 seconds -- 86.96462782500518 FPS Generated segmentations in 0.011469125747680664 seconds -- 87.1906038873298 FPS Generated segmentations in 0.011708974838256836 seconds -- 85.40457331351429 FPS Generated segmentations in 0.011548042297363281 seconds -- 86.59476422495665 FPS Generated segmentations in 0.011418342590332031 seconds -- 87.57838469890586 FPS Generated segmentations in 0.01206517219543457 seconds -- 82.88319336033989 FPS Generated segmentations in 0.011431455612182617 seconds -- 87.47792354057606 FPS Generated segmentations in 0.0111236572265625 seconds -- 89.89849108367626 FPS Generated segmentations in 0.010841846466064453 seconds -- 92.23521132955095 FPS Generated segmentations in 0.010785341262817383 seconds -- 92.71843844640449 FPS Generated segmentations in 0.010878801345825195 seconds -- 91.92189177935086 FPS Generated segmentations in 0.010807514190673828 seconds -- 92.52821530994926 FPS Generated segmentations in 0.010857343673706055 seconds -- 92.10355958628868 FPS Generated segmentations in 0.010789155960083008 seconds -- 92.68565619958898 FPS Generated segmentations in 0.010899066925048828 seconds -- 91.75097344358402 FPS Generated segmentations in 0.010824441909790039 seconds -- 92.38351578159072 FPS Generated segmentations in 0.010749101638793945 seconds -- 93.03103027614506 FPS

    note that it doesn't count the image loading and parsing

    So you might want to use this repo, it's well coded and easy to understand

    Originally posted by @MathiasGilson in https://github.com/aitorzip/Keras-ICNet/issues/2#issuecomment-377172106

    opened by Manuscript1024 0
  • This keras implementation has different order of bn and activation

    This keras implementation has different order of bn and activation

    Hi, thank you for your work. One thing I want to point out here is that you have some tiny difference compared with original implementaion, which may lead to more latency. Your implementation here is conv + activation + bn as shown below:

    y = Conv2D(32, 3, strides=2, padding='same', activation='relu', name='conv1_1_3x3_s2')(y)
    y = BatchNormalization(name='conv1_1_3x3_s2_bn')(y)
    

    But the original caffe implementaion is conv + bn + activation, which normally won't have much differnce, but this kind of order make it possible to merge bn into conv, thus leads to smaller latency.

    opened by pgr2015 0
  • NameError: name 'tf' is not defined when I loda the checkpoint file at training.

    NameError: name 'tf' is not defined when I loda the checkpoint file at training.

    After I trained on my own dataset with width 800 height 480 without checkpoint successfully, I fill in the checkpoint parameter and tried the test image and this error showed up. The exact error is like this:

    Traceback (most recent call last): File "train", line 55, in net = load_model(opt.checkpoint) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\saving.py", line 225, in deserialize_model model = model_from_config(model_config, custom_objects=custom_objects) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\saving.py", line 458, in model_from_config return deserialize(config, custom_objects=custom_objects) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\layers_init.py", line 55, in deserialize printable_module_name='layer') File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\network.py", line 1032, in from_config process_node(layer, node_data) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\network.py", line 991, in process_node layer(unpack_singleton(input_tensors), **kwargs) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\base_layer.py", line 457, in call output = self.call(inputs, **kwargs) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\layers\core.py", line 687, in call return self.function(inputs, **arguments) File "C:\Users\In-Car DVR\Desktop\DZY-work\Keras-ICNet-master\model.py", line 195, in y = Lambda(lambda x: tf.image.resize_bilinear(x, size=(int(x.shape[1])//2, int(x.shape[2])//2)), name='data_sub2')(x) NameError: name 'tf' is not defined

    The training process showed the same error when I put in the checkpoint parameters. Is the file in the output folder the checkpoint file? Or the checkpoint file is in some other locations?
    

    Thanks in advance!

    opened by zeyuDai2018 1
  • Can't build the output

    Can't build the output

    Hi,

    I have trained the model and I am trying to visualize the predictions, however I am having trouble. The error occurs on the second last line; output = apply_color_map(np.argmax(y[0], axis=-1), labels) I also noticed that there is y[1] and y[3], as well.

    Can anyone help me please?

    opened by The-Engineer9 0
  • the accuracy of the testing results

    the accuracy of the testing results

    Hi, I wonder to know your accuracy of the predicted results. How did you calculate the testing results? IoU or other methods? Because I apply this program to my own dataset, I get the very low accuracy.

    opened by Pan-zhaoyu 0
  • train  loss

    train loss

    @aitorzip Hi, thanks your great repo, when I train in my dataset, I find such following default, every new epoch loss fall from the beginning ,not from the last epoch , why does it happen ?

    opened by feitiandemiaomi 1
  • Missing conv layers in the pyramid pooling module of first branch?

    Missing conv layers in the pyramid pooling module of first branch?

    In the original PSPnet ,there appear to be a projection conv after the feature map is pooled, but it seems to be lefted out in this repo. So can a convolution between pooling and upsample help improve performance, did anyone test that?

    opened by Alexlastname 0
Owner
Aitor Ruano
My projects are a reflection of my interests at any given point in time. I :heart: Python.
Aitor Ruano
Official Implementation of HRDA: Context-Aware High-Resolution Domain-Adaptive Semantic Segmentation

HRDA: Context-Aware High-Resolution Domain-Adaptive Semantic Segmentation by Lukas Hoyer, Dengxin Dai, and Luc Van Gool [Arxiv] [Paper] Overview Unsup

Lukas Hoyer 149 Dec 28, 2022
Real-Time High-Resolution Background Matting

Real-Time High-Resolution Background Matting Official repository for the paper Real-Time High-Resolution Background Matting. Our model requires captur

Peter Lin 6.1k Jan 3, 2023
A keras-based real-time model for medical image segmentation (CFPNet-M)

CFPNet-M: A Light-Weight Encoder-Decoder Based Network for Multimodal Biomedical Image Real-Time Segmentation This repository contains the implementat

null 268 Nov 27, 2022
HyperSeg: Patch-wise Hypernetwork for Real-time Semantic Segmentation Official PyTorch Implementation

: We present a novel, real-time, semantic segmentation network in which the encoder both encodes and generates the parameters (weights) of the decoder. Furthermore, to allow maximal adaptivity, the weights at each decoder block vary spatially. For this purpose, we design a new type of hypernetwork, composed of a nested U-Net for drawing higher level context features

Yuval Nirkin 182 Dec 14, 2022
Boosting Monocular Depth Estimation Models to High-Resolution via Content-Adaptive Multi-Resolution Merging

Boosting Monocular Depth Estimation Models to High-Resolution via Content-Adaptive Multi-Resolution Merging This repository contains an implementation

Computational Photography Lab @ SFU 1.1k Jan 2, 2023
Real-Time-Student-Attendence-System - Real Time Student Attendence System

Real-Time-Student-Attendence-System The Student Attendance Management System Pro

Rounak Das 1 Feb 15, 2022
FANet - Real-time Semantic Segmentation with Fast Attention

FANet Real-time Semantic Segmentation with Fast Attention Ping Hu, Federico Perazzi, Fabian Caba Heilbron, Oliver Wang, Zhe Lin, Kate Saenko , Stan Sc

Ping Hu 42 Nov 30, 2022
DFFNet: An IoT-perceptive Dual Feature Fusion Network for General Real-time Semantic Segmentation

DFFNet Paper DFFNet: An IoT-perceptive Dual Feature Fusion Network for General Real-time Semantic Segmentation. Xiangyan Tang, Wenxuan Tu, Keqiu Li, J

null 4 Sep 23, 2022
An image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testingAn image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testing

SVM Données Une base d’images contient 490 images pour l’apprentissage (400 voitures et 90 bateaux), et encore 21 images pour fait des tests. Prétrait

Achraf Rahouti 3 Nov 30, 2021
Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation)

Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation) Download Synthia dataset The model uses

null 32 Sep 21, 2022
Tensorflow2 Keras-based Semantic Segmentation Models Implementation

Tensorflow2 Keras-based Semantic Segmentation Models Implementation

Hah Min Lew 1 Feb 8, 2022
Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data

Real-ESRGAN Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data Ported from https://github.com/xinntao/Real-ESRGAN Depend

Holy Wu 44 Dec 27, 2022
Real-CUGAN - Real Cascade U-Nets for Anime Image Super Resolution

Real Cascade U-Nets for Anime Image Super Resolution 中文 | English ?? Real-CUGAN

tarsin 111 Dec 28, 2022
Official repository for "Restormer: Efficient Transformer for High-Resolution Image Restoration". SOTA for motion deblurring, image deraining, denoising (Gaussian/real data), and defocus deblurring.

Restormer: Efficient Transformer for High-Resolution Image Restoration Syed Waqas Zamir, Aditya Arora, Salman Khan, Munawar Hayat, Fahad Shahbaz Khan,

Syed Waqas Zamir 906 Dec 30, 2022
Implementation of CVPR 2020 Dual Super-Resolution Learning for Semantic Segmentation

Dual super-resolution learning for semantic segmentation 2021-01-02 Subpixel Update Happy new year! The 2020-12-29 update of SISR with subpixel conv p

Sam 79 Nov 24, 2022
Official implement of Paper:A deeply supervised image fusion network for change detection in high resolution bi-temporal remote sening images

A deeply supervised image fusion network for change detection in high resolution bi-temporal remote sensing images 深度监督影像融合网络DSIFN用于高分辨率双时相遥感影像变化检测 Of

Chenxiao Zhang 135 Dec 19, 2022
This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras)

Yogi-Optimizer_Keras This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras) The NeurIPS-Paper can be found here: http://papers.nips.c

null 14 Sep 13, 2022
Keras udrl - Keras implementation of Upside Down Reinforcement Learning

keras_udrl Keras implementation of Upside Down Reinforcement Learning This is me

Eder Santana 7 Jan 24, 2022
Implementation for the paper 'YOLO-ReT: Towards High Accuracy Real-time Object Detection on Edge GPUs'

YOLO-ReT This is the original implementation of the paper: YOLO-ReT: Towards High Accuracy Real-time Object Detection on Edge GPUs. Prakhar Ganesh, Ya

null 69 Oct 19, 2022