Giter Club home page Giter Club logo

people_segmentation's Introduction

Binary segmentation of people

Installation

pip install -U people_segmentation

Example inference

Jupyter notebook with the example: Open In Colab

Data

Train set:

  • Mapillary Vistas Commercial 1.2 (train)
  • COCO (train)
  • Pascal VOC (train)
  • Human Matting

Validation set:

  • Mapillary Vistas Commercial 1.2 (val)
  • COCO (val)
  • Pascal VOC (val)
  • Supervisely

To convert datasets to the format:

training
    coco
    matting_humans
    pascal_voc
    vistas

validation
    coco
    pascal_voc
    supervisely
    vistas

use this set of scipts.

Training

Define the config.

Example at people_segmentation/configs

You can enable / disable datasets that are used for training and validation.

Define the environmental variable TRAIN_PATH that points to the folder with train dataset.

Example:

export TRAIN_PATH=<path to the tranining folder>

Define the environmental variable VAL_PATH that points to the folder with validation dataset.

Example:

export VAL_PATH=<path to the validation folder>

Training

python -m people_segmentation.train -c <path to config>

You can check the loss and validation curves for the configs from people_segmentation/configs at W&B dashboard

Inference

python -m torch.distributed.launch --nproc_per_node=<num_gpu> people_segmentation/inference.py \
                                   -i <path to images> \
                                   -c <path to config> \
                                   -w <path to weights> \
                                   -o <output-path> \
                                   --fp16

Web App

https://peoplesegmentation.herokuapp.com/

Code for the web app: https://github.com/ternaus/people_segmentation_demo

people_segmentation's People

Contributors

ternaus 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

people_segmentation's Issues

Fatal Python error: init_sys_streams: <stdin> is a directory, cannot continue Python runtime state: core initialized

When I run "python -m torch.distributed.launch --nproc_per_node=1 people_segmentation/inference.py \ -i <validation/supervisely> \ -c <people_segmentation/configs/2020-09-25.yaml> \ -w <weight/w.pth> \ -o \ --fp16
"

I meet some problem:
Fatal Python error: init_sys_streams: is a directory, cannot continue
Python runtime state: core initialized

Current thread 0x00007f9c81ecf740 (most recent call first):

Can you help me to solve it? Thank you!

Inference performance with fp16

hi @ternaus

thanks for this great repo!

I tried to inference with GPU, and all works ok. I have a RTX 3090, so a resonably powerful gpu.

When I run the model on a 1080p video composed of 353 frames, if I time specifically the model prediction calls only, I get 60.3fps 17.66fps (I forgot to put some torch.cuda.synchronise() to time gpu time properly).

Now if I try to run it with fp16 I get 62.8 23.96fps.

I did expect a much faster speedup with fp16. What speedup do you observe on your end when using fp16?

thanks a lot

Fail instalation on Windows virtualenv

Execute the command: pip install people_segmentation

The error generated is:
ERROR: Could not install packages due to an OSError: [WinError 5] Acceso denegado: 'C:\Users\Johan\Documents\Projects\Python\DestripaFrames\env\Lib\site-packages\cv2\cv2.pyd'
Check the permissions.

The system is:

  • OS: Windows 11 22H2 (compilation 22621.1610)
  • Python: 3.10.9 (virtualenv)
  • pip: 22.3.1

The whole output generated is:
Collecting people_segmentation
Using cached people_segmentation-0.0.4-py2.py3-none-any.whl (9.7 kB)
Collecting iglovikov-helper-functions
Using cached iglovikov_helper_functions-0.0.53-py2.py3-none-any.whl (64 kB)
Collecting albumentations
Using cached albumentations-1.3.0-py3-none-any.whl (123 kB)
Collecting pytorch-lightning
Using cached pytorch_lightning-2.0.1.post0-py3-none-any.whl (718 kB)
Collecting segmentation-models-pytorch
Using cached segmentation_models_pytorch-0.3.2-py3-none-any.whl (106 kB)
Requirement already satisfied: torch in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from people_segmentation) (2.0.0+cu118)
Requirement already satisfied: tqdm in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from people_segmentation) (4.65.0)
Collecting pytorch-toolbelt
Using cached pytorch_toolbelt-0.6.2-py3-none-any.whl (157 kB)
Collecting scikit-image>=0.16.1
Using cached scikit_image-0.20.0-cp310-cp310-win_amd64.whl (23.7 MB)
Collecting qudida>=0.0.4
Using cached qudida-0.0.4-py3-none-any.whl (3.5 kB)
Requirement already satisfied: scipy in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from albumentations->people_segmentation) (1.10.1)
Requirement already satisfied: numpy>=1.11.1 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from albumentations->people_segmentation) (1.24.2)
Requirement already satisfied: PyYAML in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from albumentations->people_segmentation) (6.0)
Collecting opencv-python-headless>=4.1.1
Using cached opencv_python_headless-4.7.0.72-cp37-abi3-win_amd64.whl (38.1 MB)
Requirement already satisfied: Pillow in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from iglovikov-helper-functions->people_segmentation) (9.3.0)
Collecting jpeg4py
Using cached jpeg4py-0.1.4.tar.gz (12 kB)
Preparing metadata (setup.py) ... done
Collecting joblib
Using cached joblib-1.2.0-py3-none-any.whl (297 kB)
Requirement already satisfied: addict in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from iglovikov-helper-functions->people_segmentation) (2.4.0)
Collecting imagecorruptions
Using cached imagecorruptions-1.1.2-py3-none-any.whl (2.1 MB)
Collecting scikit-learn
Using cached scikit_learn-1.2.2-cp310-cp310-win_amd64.whl (8.3 MB)
Requirement already satisfied: opencv-python in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from iglovikov-helper-functions->people_segmentation) (4.7.0.72)
Collecting pandas
Using cached pandas-2.0.0-cp310-cp310-win_amd64.whl (11.2 MB)
Collecting lightning-utilities>=0.7.0
Using cached lightning_utilities-0.8.0-py3-none-any.whl (20 kB)
Collecting torchmetrics>=0.7.0
Using cached torchmetrics-0.11.4-py3-none-any.whl (519 kB)
Collecting fsspec[http]>2021.06.0
Using cached fsspec-2023.4.0-py3-none-any.whl (153 kB)
Requirement already satisfied: typing-extensions>=4.0.0 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from pytorch-lightning->people_segmentation) (4.4.0)
Requirement already satisfied: packaging>=17.1 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from pytorch-lightning->people_segmentation) (23.1)
Requirement already satisfied: sympy in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from torch->people_segmentation) (1.11.1)
Requirement already satisfied: networkx in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from torch->people_segmentation) (3.0)
Requirement already satisfied: filelock in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from torch->people_segmentation) (3.9.0)
Requirement already satisfied: jinja2 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from torch->people_segmentation) (3.1.2)
Requirement already satisfied: colorama in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from tqdm->people_segmentation) (0.4.6)
Requirement already satisfied: torchvision in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from pytorch-toolbelt->people_segmentation) (0.15.1+cu118)
Collecting pretrainedmodels==0.7.4
Using cached pretrainedmodels-0.7.4.tar.gz (58 kB)
Preparing metadata (setup.py) ... done
Collecting efficientnet-pytorch==0.7.1
Using cached efficientnet_pytorch-0.7.1.tar.gz (21 kB)
Preparing metadata (setup.py) ... done
Collecting timm==0.6.12
Using cached timm-0.6.12-py3-none-any.whl (549 kB)
Collecting munch
Using cached munch-2.5.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: huggingface-hub in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from timm==0.6.12->segmentation-models-pytorch->people_segmentation) (0.13.4)
Collecting aiohttp!=4.0.0a0,!=4.0.0a1
Using cached aiohttp-3.8.4-cp310-cp310-win_amd64.whl (319 kB)
Requirement already satisfied: requests in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from fsspec[http]>2021.06.0->pytorch-lightning->people_segmentation) (2.28.1)
Collecting imageio>=2.4.1
Using cached imageio-2.27.0-py3-none-any.whl (3.4 MB)
Requirement already satisfied: tifffile>=2019.7.26 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from scikit-image>=0.16.1->albumentations->people_segmentation) (2023.4.12)
Collecting lazy_loader>=0.1
Using cached lazy_loader-0.2-py3-none-any.whl (8.6 kB)
Requirement already satisfied: PyWavelets>=1.1.1 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from scikit-image>=0.16.1->albumentations->people_segmentation) (1.4.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from scikit-learn->iglovikov-helper-functions->people_segmentation) (3.1.0)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from jinja2->torch->people_segmentation) (2.1.2)
Requirement already satisfied: cffi in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from jpeg4py->iglovikov-helper-functions->people_segmentation) (1.15.1)
Requirement already satisfied: tzdata>=2022.1 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from pandas->iglovikov-helper-functions->people_segmentation) (2023.3)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from pandas->iglovikov-helper-functions->people_segmentation) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from pandas->iglovikov-helper-functions->people_segmentation) (2023.3)
Requirement already satisfied: mpmath>=0.19 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from sympy->torch->people_segmentation) (1.2.1)
Requirement already satisfied: attrs>=17.3.0 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]>2021.06.0->pytorch-lightning->people_segmentation) (22.2.0)
Collecting aiosignal>=1.1.2
Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Collecting yarl<2.0,>=1.0
Using cached yarl-1.8.2-cp310-cp310-win_amd64.whl (56 kB)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]>2021.06.0->pytorch-lightning->people_segmentation) (2.1.1)
Collecting frozenlist>=1.1.1
Using cached frozenlist-1.3.3-cp310-cp310-win_amd64.whl (33 kB)
Collecting multidict<7.0,>=4.5
Using cached multidict-6.0.4-cp310-cp310-win_amd64.whl (28 kB)
Collecting async-timeout<5.0,>=4.0.0a3
Using cached async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Requirement already satisfied: six>=1.5 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from python-dateutil>=2.8.2->pandas->iglovikov-helper-functions->people_segmentation) (1.16.0)
Requirement already satisfied: pycparser in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from cffi->jpeg4py->iglovikov-helper-functions->people_segmentation) (2.21)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from requests->fsspec[http]>2021.06.0->pytorch-lightning->people_segmentation) (1.26.13)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from requests->fsspec[http]>2021.06.0->pytorch-lightning->people_segmentation) (2022.12.7)
Requirement already satisfied: idna<4,>=2.5 in c:\users\johan\documents\projects\python\destripaframes\env\lib\site-packages (from requests->fsspec[http]>2021.06.0->pytorch-lightning->people_segmentation) (3.4)
Installing collected packages: opencv-python-headless, munch, multidict, lightning-utilities, lazy_loader, joblib, imageio, fsspec, frozenlist, async-timeout, yarl, scikit-learn, scikit-image, pandas, jpeg4py, aiosignal, torchmetrics, qudida, imagecorruptions, efficientnet-pytorch, aiohttp, timm, pytorch-toolbelt, pretrainedmodels, iglovikov-helper-functions, albumentations, segmentation-models-pytorch, pytorch-lightning, people_segmentation
ERROR: Could not install packages due to an OSError: [WinError 5] Acceso denegado: 'C:\Users\Johan\Documents\Projects\Python\DestripaFrames\env\Lib\site-packages\cv2\cv2.pyd'
Check the permissions.

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.