{"id":20373169,"url":"https://github.com/st235/hse.mlincv","last_synced_at":"2026-05-28T20:31:23.314Z","repository":{"id":65289072,"uuid":"587864387","full_name":"st235/HSE.MLInCV","owner":"st235","description":"A lightweight model to segment the prominent humans in the scene in videos captured by a smartphone or web camera.","archived":false,"fork":false,"pushed_at":"2023-03-27T20:39:00.000Z","size":6733,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T20:44:00.657Z","etag":null,"topics":["computer-vision","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/st235.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-11T19:11:11.000Z","updated_at":"2023-04-07T10:16:59.000Z","dependencies_parsed_at":"2025-01-15T05:44:26.051Z","dependency_job_id":"14377d2b-dd6d-4710-a529-379ac59b2aa0","html_url":"https://github.com/st235/HSE.MLInCV","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/st235/HSE.MLInCV","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st235%2FHSE.MLInCV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st235%2FHSE.MLInCV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st235%2FHSE.MLInCV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st235%2FHSE.MLInCV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/st235","download_url":"https://codeload.github.com/st235/HSE.MLInCV/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/st235%2FHSE.MLInCV/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33626137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","python"],"created_at":"2024-11-15T01:16:58.394Z","updated_at":"2026-05-28T20:31:23.273Z","avatar_url":"https://github.com/st235.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Machine Learning in Computer Vision\n\n## Image Segmentation: separate humans from background\n\nA lightweight model to segment the prominent humans in the scene\nin videos captured by a smartphone or web camera.\nRuns in real-time (~120 FPS) on a laptop CPU via XNNPack TFLite backend.\n\nReturns a two class segmentation label (human or background) per pixel.\n\n| Original image                                            | Final classification                                                    |\n|-----------------------------------------------------------|-------------------------------------------------------------------------|\n| ![Original image](./resources/example_original_image.png) | ![Result classification](./resources/example_result_classification.png) |\n\n## Pre-configured scripts\n\nThis project contains automated [Makefile script](./Makefile). The idea behind makefile is to provide\nconvenient entry point to the project leaving setup headache behind.\n\n_🚨🚨🚨Please, do keep in mind, these scripts are an **experimental** feature.\nThe scripts **have been tested on MacOS only**. Script should run on Windows or Linux however I cannot guarantee that.\nIf you experience any issues running them consider to fall back to manual installing process **described later in this document**._\n\n### Targets\n\nMakefile provides a few callable targets. You can see them in the table below:\n\n| Target   | Description                                                                                                                  |\n|----------|------------------------------------------------------------------------------------------------------------------------------|\n| install  | activates virtual environment, installs all dependencies, including dependencies for development, activates pre-commit hooks |\n| build    | provides pre-build binaries, includes wheels                                                                                 |\n| test     | calls tests using pytest                                                                                                     |\n| format   | calls black to format codestyle                                                                                              |\n| lint     | calls pylint to check the codebase                                                                                           |\n| clean    | removes virtual environment, cleans Python cache                                                                             |\n| web-demo | runs the web-page with a library in demo mode                                                                                |\n| demo     | runs the library in demo mode                                                                                                |\n\n### Example\n\nTo make sure that everything works as intended you should call **install** target first. You can do it using the command below\n\n```bash\nmake install\n```\n\nWhen installation is complete you will see `.venv` folder. After installation is complete, you may call any target you want.\nFor example, to run demo you can use the next command:\n\n```bash\nmake demo\n```\n\n## No-building: getting the code using pip\n\nThe easiest way to install the library is to use `pip`. `Pip` can install libraries from Git repositories which\nis pretty handful for us. Use the command below to download the code:\n\n```bash\npip install git+https://github.com/st235/HSE.MLInCV.git\n```\n\nPip should install all necessary dependencies and create an alias for the app.\nThe alias is `human-segmentation`.\n\nTo run the program just call the code below:\n\n```bash\nhuman-segmentation\n```\n\nThe command will show default sample image similar to the next image.\n\n![Sample image](./resources/sample_default.png)\n\nTo test the app against different image you can specify them as\nthe first argument. See the example below:\n\n```bash\nhuman-segmentation image1.png\n```\n\n## Manual installation\n\n__You need at least Python 3.9 to run the code.__\n\n### Virtual env and dependencies\n\n#### Venv\n\nFirst of all, you need to activate virtual environment\nin your folder using the command below. This step is optional,\nhowever, can be very useful to segregate the project from your\nglobal environment.\n\n```bash\npython3 -m venv .venv\n```\n\nMoreover, please, do pay attention, that the project uses [opencv contrib](https://pypi.org/project/opencv-contrib-python/).\nSo, if you're using global environment (instead of virtual) and have\nopencv installed, please, do check if your version of opencv is the\nright one.\n\n#### Dependencies\n\nMoreover, you need to install all necessary dependencies. Luckily,\nall of them are located in [`requirements.txt`](./requirements.txt).\nYou need to run the following command to install all of them.\n\n```bash\npip install -r requirements.txt\n```\n\nNow you're good to go! Hooray 🎉\n\n### Option 1: build from source using `build`\n\nOne can build the app from source.\n\nPlease, note that you need [build](https://pypi.org/project/build/) installed. To do so you need to run\n\n```bash\npip install build\n```\n\nFirst step would be to build wheels from the source code. To do so you need to run __build__.\n\n```bash\npython3 -m build .\n```\n\nWhen the build is finished you are able to install the library from the produced wheel file.\nA command can look like something below:\n\n```bash\npip install dist/human_segmentation-0.0.1-py3-none-any.whl\n```\n\nIt will start the same installation process as `pip` usually do. After the app is installed successfully\nyou may call it using `human-segmentation` command. For example,\n\n```bash\nhuman-segmentation\n```\n\n## Option 2: run demo as a script\n\nAnd the last but not least is to run the app manually using [`demo.py`](./demo.py) script.\n\nYou can use the next command to run the script to see the sample image:\n\n```bash\npython3 demo.py\n```\n\nand a slightly different command to test the app against different images:\n\n```bash\npython3 demo.py ./samples/house_01.png\n```\n\nAs the result you will see something similar to the image below.\n\n![Script results](./resources/script_output.png)\n\n### Development and contribution\n\nTo start local development in the repo, please, ensure that you have all code quality control tools installed.\n\nTo do so you need to run a few more commands __(additionally to the [manual installation commands](#manual-installation))__\nin the same order as below:\n\n1. Install all dependencies: both production and dev.\nDev dependencies add `linter`, `style formatter`, `pre-commit tools`, and `test runner`.\n\n```\npip install -r requirements.txt\npip install -r dev-requirements.txt\n```\n\n2. Install pre-commit hooks. This step is not necessary, however, the same checks will be performed on the server side\nwhen one creates Pull Request.\n\n```\npre-commit install\n```\n\n#### Style formatter: black\n\n- Code formatting tool\n- Black configuration is located at [pyproject.toml](./pyproject.toml)\n- To run black locally one may need to call `black .`\n\n#### Linter: pylint\n\n- Linter\n- Pylint configuration is located at [pyproject.toml](./pyproject.toml)\n- To run pylint locally one may need to call `pylint src`\n\n#### Pre-commit\n\n- Pre-commit hooks\n- Configuration is located at [the special config](./.pre-commit-config.yaml)\n- Command runs automatically on every commit, however, to manually test hooks one may want to call `pre-commit run --all-files`\n\n#### Tests\n\nYou can run tests by executing the following command\n\n```\npytest .\n```\n\nAlso, the repository contains regression tests. Long story short: regression tests are assuming that the old\nstate of the system is correct, therefore at some point you need to generate them. To do so, just call `pytest` with\nadditional command `--overwrite-regression-result`.\n\nSee example below:\n\n```\npytest . --overwrite-regression-result\n```\n\n## Web-Page demo\n\nThe project also supports web-page demo.\n\n### Build via docker\n\nTo build an image you may want to run the command similar to the command below:\n\n```bash\ndocker build -t web_demo .\n```\n\nDocker will use [default Dockerfile](./Dockerfile) to build an image. To run the container you need to specify image and\nport.\n\n```bash\ndocker run -p 8000:8000 web_demo\n```\n\nPlease, do pay attention that you need **to map ports** using `-p` command.\n\nThe app will print something similar to\n\n```\nCollecting usage statistics. To deactivate, set browser.gatherUsageStats to False.\n\n\n  You can now view your Streamlit app in your browser.\n\n  URL: http://0.0.0.0:8000\n```\n\nOpen the app using `localhost:8000`.\n\n### Local build\n\nYou can start web page using the command below:\n\n```bash\nmake web-demo\n```\n\nor you can manually install everything to start web-app\n\n```bash\npython -m pip install streamlit\nstreamlit run web_demo.py\n```\n\n### Description\n\nWeb app allows you to pick up an image from you local files or web cam\nand apply background segregation on it.\nMoreover, the app support background overlay like in other modern video engines.\n\n| Local image                                             | Local image + background overlay                                          | Camera image + background overlay                                         |\n|---------------------------------------------------------|---------------------------------------------------------------------------|---------------------------------------------------------------------------|\n| ![Local image](./resources/webapp_demo_local_image.png) | ![Local image + background overlay](./resources/webapp_demo_local_bg.png) | ![Camera image + background overlay](./resources/webapp_demo_camera.png)  |\n\n### FAQ\n\n#### Q: Streamlit fails to run: ImportError: Missing optional dependency 'Jinja2'. DataFrame.style requires jinja2. Use pip or conda to install Jinja2.\n\nA: Something is wrong with the latest `jinja2`. Use [`pip install jinja2==3.0.1` to fix the issue.](https://discuss.streamlit.io/t/importerror-missing-optional-dependency-jinja2-dataframe-style-requires-jinja2-use-pip-or-conda-to-install-jinja2/26638)\n\n## Misc\n\nCode in this repo follows [Google's Python codestyle](https://google.github.io/styleguide/pyguide.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fst235%2Fhse.mlincv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fst235%2Fhse.mlincv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fst235%2Fhse.mlincv/lists"}