Automatic Image Background Subtraction

Overview

Automatic Image Background Subtraction

GitHub License Python Version

This repo contains set of scripts for automatic one-shot image background subtraction task using the following strategies:

  1. the appropriate background subtraction services (mostly human based):
  1. U-Net human segmentation net + CascadePSP refinement net:
  2. BackgroundMattingV2 net.

Installation

git clone https://github.com/osmr/bgsub.git
cd bgsub
pip install -r requirements.txt

Usage

  1. Launch a script for background subtraction via benzin.io/remove.bg service:
python subtract_bg_service.py --service=<service> --token=<your token> --input=<directory with images> --output=<output directory with binary masks>

Here:

  • service is benzinio for benzin.io service or removebg for remove.bg,
  • token is a service API token value, which you will receive after registering on the selected service,
  • input is a directory with processing JPEG images (can contain subdirectories),
  • output is a directory with resulted PNG binary masks (it is assumed that all original images had unique names).

Optional parameters:

  • middle is a directory with intermediate images with original masks obtained from the service (PNG with alpha mask),
  • ppdir is a flag for adding extra parrent+parrent directory to the output one (should use as --ppdir).
  • threshold is a threshold for mask binarization (default value is 127),
  • url is an optional custom URL for service,
  • jpg is a flag for forced recompression an input image as JPG (should use as --jpg),
  • not-resize is a flag for suppressing forcible scale the mask to the input image (should use as --not-resize).
  1. Launch a script for background subtraction via human segmentation network:
python subtract_bg_human.py --input=<directory with images> --output=<output directory with binary masks>

Here:

  • input is a directory with processing JPEG images (can contain subdirectories),
  • output is a directory with resulted PNG binary masks (it is assumed that all original images had unique names).

Optional parameters:

  • ppdir is a flag for adding extra parrent+parrent directory to the output one (should use as --ppdir).
  • use-cuda is a flag for using CUDA for network inference (should use as --use-cuda).
  1. Launch a script for background subtraction via matting network:
python subtract_bg_matting.py --input=<directory with images> --bg=<background image path> --output=<output directory with binary masks>

Here:

  • input is a directory with processing JPEG images (can contain subdirectories),
  • bg is a background image file path,
  • output is a directory with resulted PNG binary masks (it is assumed that all original images had unique names).

Optional parameters:

  • threshold is a threshold for mask binarization (default value is 127),
  • ppdir is a flag for adding extra parrent+parrent directory to the output one (should use as --ppdir).
  • use-cuda is a flag for using CUDA for network inference (should use as --use-cuda).

Remark

The script does not recalculate the masks if the target images already exist.

You might also like...
This repository contains several image-to-image translation models, whcih were tested for RGB to NIR image generation. The models are Pix2Pix, Pix2PixHD, CycleGAN and PointWise.

RGB2NIR_Experimental This repository contains several image-to-image translation models, whcih were tested for RGB to NIR image generation. The models

⚾🤖⚾ Automatic baseball pitching overlay in realtime
⚾🤖⚾ Automatic baseball pitching overlay in realtime

⚾ Automatically overlaying pitch motion and trajectory with machine learning! This project takes your baseball pitching clips and automatically genera

DNA-RECON { Automatic Web Reconnaissance Tool }
DNA-RECON { Automatic Web Reconnaissance Tool }

ABOUT TOOL : DNA-RECON is an automatic web reconnaissance tool written in python. This tool made for reconnaissance and information gathering with an

Combining Automatic Labelers and Expert Annotations for Accurate Radiology Report Labeling Using BERT
Combining Automatic Labelers and Expert Annotations for Accurate Radiology Report Labeling Using BERT

CheXbert: Combining Automatic Labelers and Expert Annotations for Accurate Radiology Report Labeling Using BERT CheXbert is an accurate, automated dee

PyTorch Lightning implementation of Automatic Speech Recognition

lasr Lightening Automatic Speech Recognition An MIT License ASR research library, built on PyTorch-Lightning, for developing end-to-end ASR models. In

automatic color-grading
automatic color-grading

color-matcher Description color-matcher enables color transfer across images which comes in handy for automatic color-grading of photographs, painting

Scale-aware Automatic Augmentation for Object Detection (CVPR 2021)
Scale-aware Automatic Augmentation for Object Detection (CVPR 2021)

SA-AutoAug Scale-aware Automatic Augmentation for Object Detection Yukang Chen, Yanwei Li, Tao Kong, Lu Qi, Ruihang Chu, Lei Li, Jiaya Jia [Paper] [Bi

Owner
Oleg Sémery
Mathematician
Oleg Sémery
Auditing Black-Box Prediction Models for Data Minimization Compliance

Data-Minimization-Auditor An auditing tool for model-instability based data minimization that is introduced in "Auditing Black-Box Prediction Models f

Bashir Rastegarpanah 2 Mar 24, 2022
Tianshou - An elegant PyTorch deep reinforcement learning library.

Tianshou (天授) is a reinforcement learning platform based on pure PyTorch. Unlike existing reinforcement learning libraries, which are mainly based on

Tsinghua Machine Learning Group 5.5k Jan 05, 2023
The official implementation of CircleNet: Anchor-free Detection with Circle Representation, MICCAI 2030

CircleNet: Anchor-free Detection with Circle Representation The official implementation of CircleNet, MICCAI 2020 [PyTorch] [project page] [MICCAI pap

The Biomedical Data Representation and Learning Lab 45 Nov 18, 2022
Lepard: Learning Partial point cloud matching in Rigid and Deformable scenes

Lepard: Learning Partial point cloud matching in Rigid and Deformable scenes [Paper] Method overview 4DMatch Benchmark 4DMatch is a benchmark for matc

103 Jan 06, 2023
A Pytorch implement of paper "Anomaly detection in dynamic graphs via transformer" (TADDY).

TADDY: Anomaly detection in dynamic graphs via transformer This repo covers an reference implementation for the paper "Anomaly detection in dynamic gr

Yue Tan 21 Nov 24, 2022
Harmonious Textual Layout Generation over Natural Images via Deep Aesthetics Learning

Harmonious Textual Layout Generation over Natural Images via Deep Aesthetics Learning Code for the paper Harmonious Textual Layout Generation over Nat

7 Aug 09, 2022
A particular navigation route using satellite feed and can help in toll operations & traffic managemen

How about adding some info that can quanitfy the stress on a particular navigation route using satellite feed and can help in toll operations & traffic management The current analysis is on the satel

Ashish Pandey 1 Feb 14, 2022
Fine-tune pretrained Convolutional Neural Networks with PyTorch

Fine-tune pretrained Convolutional Neural Networks with PyTorch. Features Gives access to the most popular CNN architectures pretrained on ImageNet. A

Alex Parinov 694 Nov 23, 2022
Joint Channel and Weight Pruning for Model Acceleration on Mobile Devices

Joint Channel and Weight Pruning for Model Acceleration on Mobile Devices Abstract For practical deep neural network design on mobile devices, it is e

11 Dec 30, 2022
Code release for ConvNeXt model

A ConvNet for the 2020s Official PyTorch implementation of ConvNeXt, from the following paper: A ConvNet for the 2020s. arXiv 2022. Zhuang Liu, Hanzi

Meta Research 4.6k Jan 08, 2023
a reimplementation of Holistically-Nested Edge Detection in PyTorch

pytorch-hed This is a personal reimplementation of Holistically-Nested Edge Detection [1] using PyTorch. Should you be making use of this work, please

Simon Niklaus 375 Dec 06, 2022
Code and Data for NeurIPS2021 Paper "A Dataset for Answering Time-Sensitive Questions"

Time-Sensitive-QA The repo contains the dataset and code for NeurIPS2021 (dataset track) paper Time-Sensitive Question Answering dataset. The dataset

wenhu chen 35 Nov 14, 2022
[CVPR 2022] Official Pytorch code for OW-DETR: Open-world Detection Transformer

OW-DETR: Open-world Detection Transformer (CVPR 2022) [Paper] Akshita Gupta*, Sanath Narayan*, K J Joseph, Salman Khan, Fahad Shahbaz Khan, Mubarak Sh

Akshita Gupta 127 Dec 27, 2022
A PyTorch implementation of Learning to learn by gradient descent by gradient descent

Intro PyTorch implementation of Learning to learn by gradient descent by gradient descent. Run python main.py TODO Initial implementation Toy data LST

Ilya Kostrikov 300 Dec 11, 2022
Large-scale Hyperspectral Image Clustering Using Contrastive Learning, CIKM 21 Workshop

Spectral-spatial contrastive clustering (SSCC) Yaoming Cai, Yan Liu, Zijia Zhang, Zhihua Cai, and Xiaobo Liu, Large-scale Hyperspectral Image Clusteri

Yaoming Cai 4 Nov 02, 2022
Implementation of the final project of the course DDA6309 Probabilistic Graphical Model

Task-aware Joint CWS and POS (TCwsPos) This is the implementation of the final project of the course DDA6309 Probabilistic Graphical Models, The Chine

Peng 1 Dec 26, 2021
A generator of point clouds dataset for PyPipes.

CloudPipesGenerator Documentation | Colab Notebooks | Video Tutorials | Master Degree website A generator of point clouds dataset for PyPipes. TODO Us

1 Jan 13, 2022
🔥 Cogitare - A Modern, Fast, and Modular Deep Learning and Machine Learning framework for Python

Cogitare is a Modern, Fast, and Modular Deep Learning and Machine Learning framework for Python. A friendly interface for beginners and a powerful too

Cogitare - Modern and Easy Deep Learning with Python 76 Sep 30, 2022
TensorFlow GNN is a library to build Graph Neural Networks on the TensorFlow platform.

TensorFlow GNN This is an early (alpha) release to get community feedback. It's under active development and we may break API compatibility in the fut

889 Dec 30, 2022