Coder Social home page Coder Social logo

jason-li-831202 / object-segmentation-web Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 2.0 46.55 MB

This project used Yolov8/AnimeGAN and Flask to accomplish the task of background segmentation , background remove and background replacement. Additionally, you can change different display styles.

License: GNU General Public License v3.0

Python 56.35% HTML 12.25% CSS 19.09% JavaScript 11.92% Dockerfile 0.39%
python flask object-detection object-segmentation onnxruntime yolov8 css html javascript background-removal

object-segmentation-web's Introduction

Object Background Removal Web using YoloV8 with Flask

Python CSS HTML JavaScript OnnxRuntime Markdown Flask Visual Studio Code Windows Docker

Web application for real-time object segmentation using Flask , YOLOv8, AnimeGANv2/v3 model in ONNX weights.

After obtaining images through the camera, it is possible to separate the target and background in the scene, and composite the target with a Web URL/Local Path video background. Additionally, you can change different display styles and save a screenshot.

➤ Contents

  1. Requirements

  2. ONNX-Model

  3. Examples

  4. Docker

  5. Demo

  6. Updates

  7. License

➤ Requirements

  • OpenCV, Flask, gevent, onnxruntime and youtube-dl.

  • Install :

    The requirements.txt file should list all Python libraries that your notebooks depend on, and they will be installed using:

    pip install -r requirements.txt
    
  • Note :

    If you use a YouTube URL as the link to replace your background, please make sure to modify the following.

    1. YouTube Unable to extract uploader id, so you need to revise [Your Path]\site-packages\youtube_dl\extractor\youtube.py :
    • 'uploader_id': self._search_regex(r'/(?:channel|user)/([^/?&#]+)', owner_profile_url, 'uploader id') if owner_profile_url else None,

      $\Downarrow$

    • 'uploader_id': self._search_regex(r'/(?:channel/|user/|@)([^/?&#]+)', owner_profile_url, 'uploader id', default=None),

    1. Youtube does no longer have a like/dislike count, so you need to comment out [Your Path]\site-packages\pafy\backend_youtube_dl.py :
    • self._likes = self._ydl_info['like_count']

    • self._dislikes = self._ydl_info['dislike_count']

➤ ONNX-model

You can convert the YOLOv8-seg model to ONNX using the following Google Colab notebook : Open In Colab

  • The License of the models is GPL-3.0 license: License
  • Quantize ONNX models :

    Converting a model to use float16 instead of float32 can decrease the model size.

    python onnxQuantization.py -i <path-of-your-onnx-model>
    

➤ Examples

  • Setting Config :

    model_config = {
        "model_path": 'models/yolov8n-seg-coco.onnx', # model path
        "classes_path" : 'models/coco_label.txt', # classes path
        "box_score" : 0.4,
        "box_nms_iou" : 0.45,
        "box_aspect_ratio" : None,
        "box_stretch" : None,
    }
    
    cam_config = {
        "cam_id" : 0,
        'exposure': -2, # init cam exposure
        'contrast': 50 # init cam contrast
    }

    After running, the config information will appear above the menu :

  • Run :

    python Application.py
    ... 
    The server will be accessible at [ http://localhost:8080 ].
    
    Display Mode Describe
    DisplayType.NONE Just show your webcam image.
    DisplayType.BASIC_MODE Show detect and segmentation target results on image.
    DisplayType.DETECT_MODE Separate the target box and background on image.
    DisplayType.SEMANTIC_MODE Separate the target segmentation and background on image.

➤ Docker

From the root directory, run :

docker build -t <name-of-your-image> -f ./docker/Dockerfile .
docker run --rm --privileged --device="/dev/video0:/dev/video0" -t -p 8080:8080 <name-of-your-image>

➤ Demo

➤ Updates

  • 2023/05/05 - Added images with downloadable transparent backgrounds.
  • 2023/11/22 - Fixed youtube_dl bug, and remove pafy package.
  • 2023/11/26 - Fixed custom diff model size.

➤ License

WiFi Analyzer is licensed under the GNU General Public License v3.0 (GPLv3).

GPLv3 License key requirements :

  • Disclose Source
  • License and Copyright Notice
  • Same License
  • State Changes

object-segmentation-web's People

Contributors

jason-li-831202 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

object-segmentation-web's Issues

The approach to great projects

I'm just an AI student, but I'm really impressed with the projects from ADAS to here. And the Chinese are really good. Can you suggest me how to approach repos like this regarding CV. I don't know where to start, I just want to improve my ability in Computer Vision. 非常感谢

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.