djbielejeski / a-person-mask-generator Goto Github PK
View Code? Open in Web Editor NEWExtension for Automatic1111 and ComfyUI to automatically create masks for Background/Hair/Body/Face/Clothes in Img2Img
License: MIT License
Extension for Automatic1111 and ComfyUI to automatically create masks for Background/Hair/Body/Face/Clothes in Img2Img
License: MIT License
When I enable the extension, the mask preview is blank. If I click generate, it gives me this error.
*** Error running before_process: G:\AI\StableDiffusion\stable-diffusion-webui\extensions\a-person-mask-generator\scripts\a_person_mask_generator.py
Traceback (most recent call last):
File "G:\AI\StableDiffusion\stable-diffusion-webui\modules\scripts.py", line 710, in before_process
script.before_process(p, *script_args)
File "G:\AI\StableDiffusion\stable-diffusion-webui\extensions\a-person-mask-generator\scripts\a_person_mask_generator.py", line 310, in before_process
p.image_mask = self.generate_mask(image=p.init_images[-1], mask_targets=mask_targets, mask_dilation=inpaint_dilation)
File "G:\AI\StableDiffusion\stable-diffusion-webui\extensions\a-person-mask-generator\scripts\a_person_mask_generator.py", line 65, in generate_mask
options = ImageSegmenterOptions(base_options=BaseOptions(model_asset_path=model_path),
TypeError: ImageSegmenterOptions.init() got an unexpected keyword argument 'output_category_mask'
I'm on a1111 v1.7.0
Attempted to use face mask on img2img but nothing change on face. I enabled the override mask settings, It create the mask but do not modify the image. No error on console.
Also seem not working with dynamic prompts, the console return an error message about incorrect params when I use a dynamic prompt.
Can you add an upload function?
Where:
At the mask preview.
Why:
So that you can edit the mask (example: photoshop) and then upload it.
in automatic1111, its tooo good one , can you do it for comfy ui version
Great addition thank you!
Using the feature with the first image in inpaint always works.
When pasting a new image in inpaint source image the mask preview keeps showing the previous source image mask
Work around is to click on "copy image to sketch" button and back to "copy image to inpaint" button will cause mask preview to show the new source image mask again.
To replicate:
it will show the mask correctly
Proposed solution:
The Img tab does not show the picture. When I try to generate it, it gives an error. Please help/!
Error running before_process: /content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/a-person-mask-generator/scripts/a_person_mask_generator.py
Traceback (most recent call last):
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/scripts.py", line 611, in before_process
script.before_process(p, *script_args)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/a-person-mask-generator/scripts/a_person_mask_generator.py", line 293, in before_process
p.image_mask = self.generate_mask(image=p.init_images[-1], mask_targets=mask_targets)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/a-person-mask-generator/scripts/a_person_mask_generator.py", line 65, in generate_mask
options = ImageSegmenterOptions(base_options=BaseOptions(model_asset_path=model_path),
TypeError: ImageSegmenterOptions.init() got an unexpected keyword argument 'output_category_mask'
activating the extension throws Error
Expecting value: line 1 column 1 (char 0) error on webui, after disabling the extension there is no error
Traceback (most recent call last):
File "E:\ComfyUI\Blender_ComfyUI\ComfyUI\custom_nodes\a-person-mask-generator\install.py", line 1, in
import launch
File "E:\ComfyUI\Blender_ComfyUI\python_embeded\lib\site-packages\launch_init_.py", line 9, in
from .cli import *
File "E:\ComfyUI\Blender_ComfyUI\python_embeded\lib\site-packages\launch\cli.py", line 12, in
from .app import App
File "E:\ComfyUI\Blender_ComfyUI\python_embeded\lib\site-packages\launch\app.py", line 11, in
from flowdas import meta
ImportError: cannot import name 'meta' from 'flowdas' (E:\ComfyUI\Blender_ComfyUI\python_embeded\lib\site-packages\flowdas_init_.py)
Environment | Version |
---|---|
Stable Diffusion | v1.6.0-2-g4afaaf8a |
A Person Mask Generator | commit: 04cad56 |
At the img2img
mode, it works perfectly. But when clicking Generate
button at the txt2img
tab, it will trigger an error:
*** Error running before_process: \path\to\StableDiffusion\stable-diffusion-webui\extensions\a-person-mask-generator\scripts\a_person_mask_generator.py
Traceback (most recent call last):
File "\path\to\StableDiffusion\stable-diffusion-webui\modules\scripts.py", line 611, in before_process
script.before_process(p, *script_args)
TypeError: Script.before_process() missing 2 required positional arguments: 'enabled' and 'mask_targets'
It seems that the bug is caused by no arguments to submit at the txt2img
mode while before_process()
is wrongly triggered to require two non-exist arguments. May fix it by adding a tab/mode check.
Hello, thanks for your nice job.
Do you plan to expand access via API?
For example send result mask as base64 png transparent image, thanks in advance...
Hi! Thank you for the extension, but I was unable to install it.
Mac mini M1 8Gb
A1111 version: v1.6.0-2-g4afaaf8a
./webui.sh --opt-split-attention-v1
*** Error loading script: a_person_mask_generator.py
Traceback (most recent call last):
File "/Users/admin/Documents/projects/sd/modules/scripts.py", line 382, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "/Users/admin/Documents/projects/sd/modules/script_loading.py", line 10, in load_module
module_spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/admin/Documents/projects/sd/extensions/a-person-mask-generator/scripts/a_person_mask_generator.py", line 8, in <module>
import mediapipe as mp
File "/Users/admin/Documents/projects/sd/venv/lib/python3.10/site-packages/mediapipe/__init__.py", line 16, in <module>
import mediapipe.python.solutions as solutions
File "/Users/admin/Documents/projects/sd/venv/lib/python3.10/site-packages/mediapipe/python/solutions/__init__.py", line 17, in <module>
import mediapipe.python.solutions.drawing_styles
File "/Users/admin/Documents/projects/sd/venv/lib/python3.10/site-packages/mediapipe/python/solutions/drawing_styles.py", line 20, in <module>
from mediapipe.python.solutions.drawing_utils import DrawingSpec
File "/Users/admin/Documents/projects/sd/venv/lib/python3.10/site-packages/mediapipe/python/solutions/drawing_utils.py", line 24, in <module>
from mediapipe.framework.formats import detection_pb2
File "/Users/admin/Documents/projects/sd/venv/lib/python3.10/site-packages/mediapipe/framework/formats/detection_pb2.py", line 5, in <module>
from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/Users/admin/Documents/projects/sd/venv/lib/python3.10/site-packages/google/protobuf/internal/__init__.py)
Good afternoon, the problem is the following - in the browser, using the module, changes clothes perfectly. Unniffed the request, prescribed parameters in the api http://127.0.0.1:7860/sdapi/v1/img2img - does not change clothes fully, it feels like denosing does not set, although set 0.9. Here are the parameters that I send on the api
{
"prompt": "<lora:add_detail:0.8>, <lora:more_details:0.3>, masterpiece, high quality, 8k, beautiful lighting, absurdres, perfect anatomy, ((swimsuit, blue swimsuit)), ",
"negative_prompt": "(worst quality, low quality, ugly:1.4), (deformed, distorted, disfigured:1.3), stacked torsos, totem pole, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, text, watermark",
"sampler_name": "Euler a",
"styles": [],
"seed": -1,
"subseed": -1,
"subseed_strength": 0,
"seed_resize_from_h": -1,
"seed_resize_from_w": -1,
"batch_size": 1,
"n_iter": 1,
"steps": 24,
"cfg_scale": 7,
"width": 640,
"height": 848,
"restore_faces": false,
"tiling": false,
"do_not_save_samples": false,
"do_not_save_grid": false,
"eta": 0,
"denoising_strength": 0.9,
"s_min_uncond": 0,
"s_churn": 0,
"s_tmax": 0,
"s_tmin": 0,
"s_noise": 0,
"override_settings": {},
"disable_extra_networks": false,
"comments": {},
"init_images": [
"base64 our images"
],
"send_images": true,
"save_images": false,
"alwayson_scripts": {
"A Person Mask Generator": {
"args": [
true,
[
"clothes"
],
true,
4,
0,
1,
false, (or true - not change nothing)
256,
8
]
}
}
}
Been racking my brain for a couple days now that I haven't changed it already. What is the problem and what to do, please tell me. Thanks in advance
The first image is taken via the web. Models etc. are the same, all parameters are the same
Liked your project so much, thank you! And I believe it would be great to add mask blur option (+4 px feathering for example) because I notices the contours appear frequently
This is not an issue but more like a request. Can we have options to set (assuming the background-only option is chosen) the background color to be solid white, black, chroma green (#00b140), or chroma blue (#0047BB) instead of a randomly generated background from prompts?
As far as I've noticed, the precision is phenomenal, but the model has a pretty significant limitation:
There is no way to detect facial hair separately, or even as part of the hair.
The extension detects the beard as part of the face.
I'm not sure if it's fixable, since it's caused by Google's mediapipe model and I don't know whether that model can be retrained, but posting it just to be thorough.
Version: commit 443e491.
How to replicate: put an image of a bearded man into img2img and use the extension to first detect hair, then face (skin).
Not a bug, rather a question/feature request. Like the title says I have been trying to find a way to get the mask only via API call. Is there a way to do this?
Error occurred when executing APersonMaskGenerator:
ImageSegmenterOptions.init() got an unexpected keyword argument 'output_category_mask'
File "E:\Blender_ComfyUI\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "E:\Blender_ComfyUI\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "E:\Blender_ComfyUI\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "E:\Blender_ComfyUI\ComfyUI\custom_nodes\a-person-mask-generator\a_person_mask_generator_comfyui.py", line 103, in generate_mask
options = mp.tasks.vision.ImageSegmenterOptions(
I really don't know how to solve it
Error occurred when executing LayerMask: PersonMaskUltra V2:
cannot import name 'VitMatteImageProcessor' from 'transformers' (H:\ComfyUI-aki-v1.3\python\lib\site-packages\transformers_init_.py)
File "H:\ComfyUI-aki-v1.3\execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "H:\ComfyUI-aki-v1.3\execution.py", line 81, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "H:\ComfyUI-aki-v1.3\execution.py", line 74, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "H:\ComfyUI-aki-v1.3\custom_nodes\ComfyUI_LayerStyle\py\person_mask_ultra_v2.py", line 154, in person_mask_ultra_v2
_mask = generate_VITMatte(orig_image, _trimap, local_files_only=local_files_only)
File "H:\ComfyUI-aki-v1.3\custom_nodes\ComfyUI_LayerStyle\py\imagefunc.py", line 1087, in generate_VITMatte
vit_matte_model = load_VITMatte_model(model_name=model_name, local_files_only=local_files_only)
File "H:\ComfyUI-aki-v1.3\custom_nodes\ComfyUI_LayerStyle\py\imagefunc.py", line 1075, in load_VITMatte_model
from transformers import VitMatteImageProcessor, VitMatteForImageMatting
Would be insanely useful to me.
when using inpaint/not masked it is sometimes helpful to mask a little bit less of the subject, however there is no mechanism to reduce the masking size, only dilate.
Error occurred when executing APersonMaskGenerator:
File "D:\ComfyUI_windows\ComfyUI\execution.py", line 149, in recursive_execute
obj = class_def()
^^^^^^^^^^^
File "D:\ComfyUI_windows\ComfyUI\custom_nodes\a-person-mask-generator\a_person_mask_generator_comfyui.py", line 39, in init
get_a_person_mask_generator_model_path()
File "D:\ComfyUI_windows\ComfyUI\custom_nodes\a-person-mask-generator\a_person_mask_generator_comfyui.py", line 30, in get_a_person_mask_generator_model_path
wget.download(model_url, model_file_path)
File "D:\ComfyUI_windows\python_embeded\Lib\site-packages\wget.py", line 526, in download
(tmpfile, headers) = ulib.urlretrieve(binurl, tmpfile, callback)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "urllib\request.py", line 241, in urlretrieve
File "urllib\request.py", line 216, in urlopen
File "urllib\request.py", line 519, in open
File "urllib\request.py", line 536, in _open
File "urllib\request.py", line 496, in _call_chain
File "urllib\request.py", line 1391, in https_open
File "urllib\request.py", line 1351, in do_open
Very nice plugin that can Identify faces and hair. Is it possible in the future it can detect head accessories like scarf or hijab
Thank you.
*** Error loading script: a_person_mask_generator.py Traceback (most recent call last): File "D:\SD\Data\Packages\Stable Diffusion WebUI\modules\scripts.py", line 382, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "D:\SD\Data\Packages\Stable Diffusion WebUI\modules\script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "D:\SD\Data\Packages\Stable Diffusion WebUI\extensions\a-person-mask-generator\scripts\a_person_mask_generator.py", line 8, in <module> import mediapipe as mp ModuleNotFoundError: No module named 'mediapipe'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.