All Projects → Algy → Fast Slic

Algy / Fast Slic

Licence: mit
20x Real-time superpixel SLIC Implementation with CPU

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Fast Slic

Midv 500 Models
Model for document segmentation trained on the midv-500-models dataset.
Stars: ✭ 31 (-67.71%)
Mutual labels:  image-segmentation
Coco Annotator
✏️ Web-based image segmentation tool for object detection, localization, and keypoints
Stars: ✭ 1,138 (+1085.42%)
Mutual labels:  image-segmentation
Keras Icnet
Keras implementation of Real-Time Semantic Segmentation on High-Resolution Images
Stars: ✭ 85 (-11.46%)
Mutual labels:  image-segmentation
Albumentations
Fast image augmentation library and an easy-to-use wrapper around other libraries. Documentation: https://albumentations.ai/docs/ Paper about the library: https://www.mdpi.com/2078-2489/11/2/125
Stars: ✭ 9,353 (+9642.71%)
Mutual labels:  image-segmentation
Unet Tensorflow
Tensorflow implement of U-Net
Stars: ✭ 50 (-47.92%)
Mutual labels:  image-segmentation
Lovaszsoftmax
Code for the Lovász-Softmax loss (CVPR 2018)
Stars: ✭ 1,148 (+1095.83%)
Mutual labels:  image-segmentation
Max Image Segmenter Web App
Deploy a Deep Learning Powered "Magic Cropping Tool" using Pre-Trained Open Source Models
Stars: ✭ 29 (-69.79%)
Mutual labels:  image-segmentation
Tf Segnet
SegNet-like network implemented in TensorFlow to use for segmenting aerial images
Stars: ✭ 93 (-3.12%)
Mutual labels:  image-segmentation
Image Segmenter Android
Realtime Image Segmentation on Android
Stars: ✭ 55 (-42.71%)
Mutual labels:  image-segmentation
Image Segmentation Fcn
Semantic Image Segmentation using a Fully Convolutional Neural Network in TensorFlow
Stars: ✭ 82 (-14.58%)
Mutual labels:  image-segmentation
Segmentation wbc
White blood cell (WBC) image datasets
Stars: ✭ 35 (-63.54%)
Mutual labels:  image-segmentation
Segmentationcpp
A c++ trainable semantic segmentation library based on libtorch (pytorch c++). Backbone: ResNet, ResNext. Architecture: FPN, U-Net, PAN, LinkNet, PSPNet, DeepLab-V3, DeepLab-V3+ by now.
Stars: ✭ 49 (-48.96%)
Mutual labels:  image-segmentation
Tensorflow Deeplab v3 plus
图像分割算法deeplab_v3+,基于tensorflow,中文注释,摄像头可用
Stars: ✭ 75 (-21.87%)
Mutual labels:  image-segmentation
Graph Based Image Segmentation
Implementation of efficient graph-based image segmentation as proposed by Felzenswalb and Huttenlocher [1] that can be used to generate oversegmentations.
Stars: ✭ 31 (-67.71%)
Mutual labels:  image-segmentation
Paddleseg
End-to-end image segmentation kit based on PaddlePaddle.
Stars: ✭ 1,244 (+1195.83%)
Mutual labels:  image-segmentation
Active Contour Model Python
The python code of Chan-Vese model and RSF model for image segmentation
Stars: ✭ 28 (-70.83%)
Mutual labels:  image-segmentation
Multiclass Semantic Segmentation Camvid
Tensorflow 2 implementation of complete pipeline for multiclass image semantic segmentation using UNet, SegNet and FCN32 architectures on Cambridge-driving Labeled Video Database (CamVid) dataset.
Stars: ✭ 67 (-30.21%)
Mutual labels:  image-segmentation
Sky Detector
Sky area detection without deep neural networks https://maybeshewill-cv.github.io/sky-detector/
Stars: ✭ 96 (+0%)
Mutual labels:  image-segmentation
Awesome Referring Image Segmentation
📚 A collection of papers about Referring Image Segmentation.
Stars: ✭ 91 (-5.21%)
Mutual labels:  image-segmentation
Attention Gated Networks
Use of Attention Gates in a Convolutional Neural Network / Medical Image Classification and Segmentation
Stars: ✭ 1,237 (+1188.54%)
Mutual labels:  image-segmentation

Fast Slic

Fast-slic is a SLIC-variant algorithm implementation that aims for significantly low runtime with cpu. It runs 7-20 times faster than existing SLIC implementations. Fast-slic can process 1280x720 image stream at 60fps.

It started as a part of my hobby project that demanded true "real time" capability in video stream processing. Among pipelines of it was a postprocessing pipeline smoothing the result of image with SLIC superpixels and CRF. Unfortunately, there were no satisfying library for real-time(>30fps) goal. gSLICr was the most promising candidate, but I couldn't make use of it due to limited hardware and inflexible license of CUDA. Therefore, I made the blazingly fast variant of SLIC using only CPU.

Paper preprint

Demo

demo_clownfish demo_tiger

Installation

pip install fast_slic

Basic Usage

import numpy as np

from fast_slic import Slic
from PIL import Image

with Image.open("fish.jpg") as f:
   image = np.array(f)
# import cv2; image = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)   # You can convert the image to CIELAB space if you need.
slic = Slic(num_components=1600, compactness=10)
assignment = slic.iterate(image) # Cluster Map
print(assignment)
print(slic.slic_model.clusters) # The cluster information of superpixels.

If your machine has AVX2 instruction set, you can make it three times faster using fast_slic.avx2.SlicAvx2 class instead of fast_slic.Slic. Haswell and newer Intel cpus, Excavator, and Ryzen support this.

import numpy as np

# Much faster than the standard class
from fast_slic.avx2 import SlicAvx2
from PIL import Image

with Image.open("fish.jpg") as f:
   image = np.array(f)
# import cv2; image = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)   # You can convert the image to CIELAB space if you need.
slic = SlicAvx2(num_components=1600, compactness=10)
assignment = slic.iterate(image) # Cluster Map
print(assignment)
print(slic.slic_model.clusters) # The cluster information of superpixels.

If your machine is ARM with NEON instruction set, which is commonly supported by recent mobile devices and even Raspberry Pi, you can make it two-fold faster by using fast_slic.neon.SlicNeon class instead of the original one.

Performance

With max iteration set to 10, run times of slic implementations for 640x480 image are as follows:

Implementation Run time(ms)
skimage.segment.slic 216ms
cv2.ximgproc.createSuperpixelSLIC.iterate 142ms
fast_slic.Slic(single core build) 20ms
fast_slic.avx2.SlicAvx2(single core build /w avx2 support) 12ms
fast_slic.Slic(w/ OpenMP support) 8.8ms
fast_slic.avx2.SlicAvx2(w/ OpenMP, avx2 support) 5.6ms

(RGB-to-CIELAB conversion time is not included. Tested with Ryzen 2600x 6C12T 4.0Hz O.C.)

Known Issues

  • Windows build is quite slower compared to those of linux and mac. Maybe it is due to openmp overhead?

Tips

  • It automatically removes small isolated area of pixels at cost of significant (but not huge) overhead. You can skip denoising process by setting min_size_factor to 0. (e.g. Slic(num_components=1600, compactness=10, min_size_factor=0)). The setting makes it 20-40% faster.
  • To push to the limit, compile it with FAST_SLIC_AVX2_FASTER flag and get more performance gain. (though performance margin was small in my pc)

TODO

  • [ ] Publish as a research paper
  • [x] Remove or merge small blobs
  • [x] Include simple CRF utilities
  • [x] Add tests
  • [x] Windows build
  • [x] More scalable parallel loop in cluster assignment. I suspect there is false sharing problem in the loop.
  • [x] would be great if I can optimize loop more. SIMD?
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].