{"id":23104142,"url":"https://github.com/extraltodeus/depthmap2mask","last_synced_at":"2025-04-06T06:13:24.985Z","repository":{"id":63846298,"uuid":"570663084","full_name":"Extraltodeus/depthmap2mask","owner":"Extraltodeus","description":"Create masks out of depthmaps in img2img","archived":false,"fork":false,"pushed_at":"2023-04-13T04:10:08.000Z","size":31,"stargazers_count":359,"open_issues_count":31,"forks_count":35,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-30T05:07:46.264Z","etag":null,"topics":["automatic1111","stable-diffusion","stable-diffusion-webui","stable-diffusion-webui-plugin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Extraltodeus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-11-25T18:52:59.000Z","updated_at":"2025-03-14T00:44:52.000Z","dependencies_parsed_at":"2024-12-18T05:33:51.456Z","dependency_job_id":null,"html_url":"https://github.com/Extraltodeus/depthmap2mask","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2Fdepthmap2mask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2Fdepthmap2mask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2Fdepthmap2mask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2Fdepthmap2mask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Extraltodeus","download_url":"https://codeload.github.com/Extraltodeus/depthmap2mask/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441059,"owners_count":20939239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["automatic1111","stable-diffusion","stable-diffusion-webui","stable-diffusion-webui-plugin"],"created_at":"2024-12-17T00:31:34.268Z","updated_at":"2025-04-06T06:13:24.965Z","avatar_url":"https://github.com/Extraltodeus.png","language":"Python","readme":"# depthmap2mask\n\nMade as a script for the [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) repository.\n\n\n## 💥 Installation 💥\n\nCopy the url of that repository into the extension tab :\n\n![image](https://user-images.githubusercontent.com/15731540/204056273-fc27d1cf-48ac-4dc3-b737-95b4b1efd32e.png)\n\nOR copy that repository in your extension folder :\n\n![image](https://user-images.githubusercontent.com/15731540/203840272-83cccb24-4417-44bc-99df-e45eb5f3360c.png)\n\nYou might need to restart the whole UI. Maybe twice.\n\nif you are on colab you can also add this line in a code block before starting the UI/after the installation cells :\n\n    !git clone https://github.com/Extraltodeus/depthmap2mask.git /content/stable-diffusion-webui/extensions/depthmap2mask\n\n## The look\n\n![image](https://user-images.githubusercontent.com/15731540/204043153-09cbffd9-28ac-46be-ad99-fc7f2c8656a3.png)\n\n## What does this extension do?\n\nIt creates masks for img2img based on a depth estimation made by [MiDaS](https://github.com/isl-org/MiDaS).\n\n![smallerone](https://user-images.githubusercontent.com/15731540/204043576-5dc02def-29f8-423e-a69e-d392f47d3602.png)![5050](https://user-images.githubusercontent.com/15731540/204043582-ae46d0b8-3c4b-43d5-b669-eaf2659ced14.png)\n\n## Where to find it after installing it?\n\nGo to your img2img tab then select it from the custom scripts list at the bottom.\n\n## Explanations of the different UI elements\n\n- Contrasts cut level\n\n![image](https://user-images.githubusercontent.com/15731540/204043824-6067bd9e-49d6-488b-8f99-47928c31ae46.png)\n\nThis slider is **purely optional**.\nThe depthmap is in levels of gray. Each pixel has a value in between 0 and 255 depending if they are black (0) or white (255). That threshold slider will cut to black every pixel below the selected value and scale from black to white what is above its value.\n\nOr in a more human language, it will give more depth to your depthmaps while removing a lot of information.\n\nExample before/after with the slider's value around 220 and using the MiDaS-Large model:\n\n![00073--1 0- sampler -85-8 1-ac07d41f-20221125174853](https://user-images.githubusercontent.com/15731540/204044001-4e672bbe-4ff8-46ef-ae87-ec3377e7aa37.png)![00074--1 0- sampler -85-8 1-ac07d41f-20221125174934](https://user-images.githubusercontent.com/15731540/204044306-80c77ba3-3b38-4ea6-941c-f6c6006c8b4e.png)\n\nUsing the MiDaS small model will give you similar if not more interesting results.\n\n![smallerone](https://user-images.githubusercontent.com/15731540/204043576-5dc02def-29f8-423e-a69e-d392f47d3602.png)![5050](https://user-images.githubusercontent.com/15731540/204043582-ae46d0b8-3c4b-43d5-b669-eaf2659ced14.png)\n\nSo that's more of an extra-extra option or a way to make sure that your backgrounds are untouched by using a low value (like 50).\n\n- Match input size/Net width/Net height\n\n![image](https://user-images.githubusercontent.com/15731540/204044819-0618bf27-0692-4a20-922f-73e33822dc6f.png)\n\nMatch input size (On by default) will make the depth analysis at the same size as the original image. Better not to touch it unless you are having performance issues.\n\nThe sliders below will be the resolution of the analysis if Match input size is turned off.\n\nYou can also just use these functionalities to test out different results.\n\n- Misc options\n\n![image](https://user-images.githubusercontent.com/15731540/204045429-778f3084-63ad-421d-ad43-af9a20c49621.png)\n\n- Override options :\n\n    These two options simply overrides the inpainting Masked content method and mask blur. I added these because using \"original\" for Masked content and Mask Blur at 0 just works better. This saves you the clics needed to switch to the intpaint tab/reupload the image to that tab and select the right options.\n    \n- MiDaS models :\n\n    I'll let you try what suits your needs the most.\n    \n- Turn the depthmap into absolute black/white\n\n![image](https://user-images.githubusercontent.com/15731540/204057815-1e7d1d38-2fbb-43a1-bb08-133e574138c2.png)\n\nThis option will cut out the background of an image into pure black and make the foreground pure white. Like a clean cut.\n\n### Alpha Cropping\n\nYou can also save a version of the input image which has had all the masked content replaced with transparent pixels. This is useful when extracting the subject from the background, so that it can be used in designs.\n\n![Image](https://i.imgur.com/yFX6LyQ.jpeg)\n\nSimply check the \"Save alpha mask\" option before generating.\n\n## Tips\n\n- Avoid using Euler a or you might get really bad results. Usually DDIM works best.\n\n## Credits/Citation\n\nThanks to [thygate](https://github.com/thygate) for letting me blatantly copy-paste some of his functions for the depth analysis integration in the webui.\n\nThis repository runs with [MiDaS](https://github.com/isl-org/MiDaS).\n\n```\n@ARTICLE {Ranftl2022,\n    author  = \"Ren\\'{e} Ranftl and Katrin Lasinger and David Hafner and Konrad Schindler and Vladlen Koltun\",\n    title   = \"Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-Shot Cross-Dataset Transfer\",\n    journal = \"IEEE Transactions on Pattern Analysis and Machine Intelligence\",\n    year    = \"2022\",\n    volume  = \"44\",\n    number  = \"3\"\n}\n```\n```\n@article{Ranftl2021,\n\tauthor    = {Ren\\'{e} Ranftl and Alexey Bochkovskiy and Vladlen Koltun},\n\ttitle     = {Vision Transformers for Dense Prediction},\n\tjournal   = {ICCV},\n\tyear      = {2021},\n}\n```\n\n## Bug reporting\n\n- Please check if similar issues exist before creating a new one.\n- Make sure to do a \"git pull\" from your webui folder in order to have your webui up to date\n- Provide as many details as possible when creating a new issue.\n\n## Examples using different MiDaS models and denoising strength\n![00056-589874964- sampler -32-7-ac07d41f-20221125174017](https://user-images.githubusercontent.com/15731540/204048931-20b19823-bba9-44be-a4ff-4d3ae65dd120.png)![00064-1584461722- sampler -32-7-ac07d41f-20221125174328](https://user-images.githubusercontent.com/15731540/204048940-fada95f2-fcb0-4cf7-ba0c-6a1fd6b904ea.png)![00100-717650490- sampler -84-8 1-ac07d41f-20221125175700](https://user-images.githubusercontent.com/15731540/204048949-a4faf745-e9b5-437e-870d-be8ea7bd4b5d.png)\n\n\n\u003csub\u003eI forgot my settings but in the end it's all pretty easy to guess what you need.\u003c/sub\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextraltodeus%2Fdepthmap2mask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextraltodeus%2Fdepthmap2mask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextraltodeus%2Fdepthmap2mask/lists"}