GithubHelp home page GithubHelp logo

mazhar004 / modnet-bgremover Goto Github PK

View Code? Open in Web Editor NEW
116.0 7.0 56.0 14.15 MB

A deep learning approach to remove background & adding new background image

Python 88.81% JavaScript 4.57% HTML 6.62%
python computer-vision opencv background-removal webcam

modnet-bgremover's Introduction

MODNet Background Remover

Application

A deep learning approach to remove background and adding new background image

  • Remove background from images,videos & live webcam
  • Adding new background to those images,videos & webcam footage

Demo

Before removing the background After replacing the background with new image
Male.jpg Male.png
Before removing the background from video After replacing the background with new image in this video
Video

Web View

Before removing the background After removing the background
Female.jpeg Female.png

Installation

Python Version

  • Python == 3.8

Virtual Environment

Windows

  • python -m venv venv
  • .\venv\Scripts\activate
  • If any problem for scripts activation
    • Execute following command in administration mode
      • Set-ExecutionPolicy Unrestricted -Force
    • Later you can revert the change
      • Set-ExecutionPolicy restricted -Force

Linux

  • python -m venv venv
  • source venv/bin/activate

Library Installation

  • Library Install
    • pip install --upgrade pip
    • pip install --upgrade setuptools
    • pip install -r requirements.txt
    • To run in web interface
      • pip install -r web_requirements.txt

Pretrained Weights Download

Inference

Image

Single image

It will generate the output file in output/ folder

  • python inference.py --image image_path [Without background image]
  • python inference.py --image image_path --background True [With background image]
  • Example:
    • python inference.py --image assets/sample_image/female.jpeg
    • python inference.py --image assets/sample_image/male.jpeg --background True

Folder of images

It will generate the output file in output/ folder

  • python inference.py --folder folder_path [Without background image]
  • python inference.py --folder folder_path --background True [With background image]
  • Example:
    • python inference.py --folder assets/sample_image/
    • python inference.py --folder assets/sample_image/ --background True

Video

It will generate the output file in output/ folder

  • python inference.py --video video_path [Without background image]
  • python inference.py --video video_path --background True [With background image]
  • Example:
    • python inference.py --video assets/sample_video/sample.mp4
    • python inference.py --video assets/sample_video/sample.mp4 --background True

Webcam

  • python inference.py --webcam True [Without background image]
  • python inference.py --webcam True --background True [With background image]

Webinterface

  • python api.py
  • Click on this link/localhost
  • Upload the image and wait

Reference

modnet-bgremover's People

Contributors

mazhar004 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

modnet-bgremover's Issues

Request: passing webcam to video device.

Thank you for the good work. It gives excellent results when cropping heads, even with curly hair.

But unfortunately the result cannot be used as a device with the webcam option. It would be nice if such an output would be added to the script.

Unfortunately, I have no idea about programming, but I imagine to forward the signal to v4linux or OBS.

Removing white Background

Hi,
I am using the code to remove a white background from the image but the results are not as expected. Any ideas on how to make it work. Attaching the result.

Resulant image
0001

Original image
0001

ask about image transparent

Hello, I want to ask. how to make background image transparent? i need transparent background image png. Thank You

Quality Output Image

Hello, I want ask. I need to change resolution image because i want
use image to print. can you help me? Thank you

CUDA error: no kernel image is available for execution on the device

I've installed BGRemover to Linux. I had some problems with torchvision version, because pip did not understand requirements.txt for some reason.

I have the following packages installed

Package Version


numpy 1.24.1
opencv-python 4.5.1.48
Pillow 6.2.2
pip 22.3.1
setuptools 65.6.3
six 1.16.0
torch 1.7.1
torchvision 0.2.2.post3
typing_extensions 4.4.0

When I run python inference.py --image

I get "Erro happend CUDA error: no kernel image is available for execution on the device"

So, should I modify torchvision version, install some additional pip package, both or something else?

Transparent output

Can the output be the video with transparent background and no image?

White lines surrounding the images

Hello, I ran your model but i see some white lines surrounding my object. Do you have any idea how to make those white lines disappear?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.