[Bug]: TypeError: 'bool' object is not subscriptable
thompshonli opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues and checked the recent builds/commits of both this extension and the webui
Have you updated WebUI and this extension to the newest version?
- I have updated WebUI and this extension to the most up-to-date version
Do you understand that you should go to https://github.com/IDEA-Research/Grounded-Segment-Anything/issues if you cannot install GroundingDINO?
- My problem is not about installing GroundingDINO
Do you know that you should use the newest ControlNet extension and enable external control if you want SAM extension to control ControlNet?
- I have updated ControlNet extension and enabled "Allow other script to control this extension"
What happened?
when use webui, and img2img,have an error, controlnet is not work, I have allowed other script to control this extension and the same time close the segment. But when I remove the segment, the controlnet is ok, img2img is ok
Steps to reproduce the problem
- Go to ....
- Press ....
- ...
What should have happened?
s
Commit where the problem happens
webui:
extension:
What browsers do you use to access the UI ?
No response
Command Line Arguments
linux .sh --xformers --api --api-log --enable-insecure-extension-access
Console logs
Error running process: /a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-segment-anything/scripts/sam.py
Traceback (most recent call last):
File "/a8root/work/sd_webui/stable-diffusion-webui_1/modules/scripts.py", line 417, in process
script.process(p, *script_args)
File "/a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-segment-anything/scripts/sam.py", line 761, in process
process_unit.set_process_attributes(p)
File "/a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-segment-anything/scripts/process_params.py", line 87, in set_process_attributes
inpaint_image, inpaint_mask = self.sam_inpaint_unit.get_input_and_mask(inpaint_mask_blur)
File "/a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-segment-anything/scripts/process_params.py", line 45, in get_input_and_mask
mask = Image.open(self.output_mask_gallery[self.output_chosen_mask + 3]['name']).convert('L')
TypeError: 'bool' object is not subscriptable
Error running process: /a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-controlnet/scripts/controlnet.py
Traceback (most recent call last):
File "/a8root/work/sd_webui/stable-diffusion-webui_1/modules/scripts.py", line 417, in process
script.process(p, *script_args)
File "/a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-controlnet/scripts/controlnet.py", line 982, in process
self.enabled_units = self.get_enabled_units(p)
File "/a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-controlnet/scripts/controlnet.py", line 944, in get_enabled_units
unit = self.parse_remote_call(p, unit, idx)
File "/a8root/work/sd_webui/stable-diffusion-webui_1/extensions/sd-webui-controlnet/scripts/controlnet.py", line 796, in parse_remote_call
unit.enabled = selector(p, "control_net_enabled", unit.enabled, idx, strict=True)
AttributeError: 'list' object has no attribute 'enabled'
100%|██████████| 31/31 [00:32<00:00, 1.05s/it][
Total progress: 100%|██████████| 31/31 [00:32<00:00, 1.04s/it]
Total progress: 100%|██████████| 31/31 [00:32<00:00, 1.34it/s]
Additional information
No response
Did you use this extension to control ControlNet, or are you just using ControlNet + img2img, but are not using Sam?
Did you use this extension to control ControlNet, or are you just using ControlNet + img2img, but are not using Sam?
Just using ControlNet + img2img, and not using Sam,
I am not able to reproduce your problem. You should do the following:
- update controlnet to v1.1.150
- click "uncheck all copies" to make sure that it is not enabled
The version should not be a problem. Please add print(script_args)
before
File "/a8root/work/sd_webui/stable-diffusion-webui_1/modules/scripts.py", line 417, in process
script.process(p, *script_args)
and send me the output. Please keep the indentation the same as script.process. I suspect that the internal script order inside your UI has not changed due to some reason. But even if the exception comes from here, I am still unable to discover the reason. Maybe some other script also did a similar stuff, which made my extension incompatible with controlnet.
Here is my output
(False, False, 0, None, [], 0, False, [], [], False, 0, 1, False, False, 0, None, [], -2, False, [])
(<controlnet.py.UiControlNetUnit object at 0x7f11898f1a00>, <controlnet.py.UiControlNetUnit object at 0x7f11897b7730>, <controlnet.py.UiControlNetUnit object at 0x7f11898eb400>)
The bool, bool, 0
like tuple should live before the controlnet unit.
It seems that something messed up the order of the arguments. Please add print(script.title(), controls)
below L324 (controls = wrap_call(script.ui, script.filename, "ui", script.is_img2img)
) of modules/scripts.py and send me the output when creating UI. If things work out correctly you should get
ControlNet (state, state, state)
Segment Anything (checkbox, checkbox, radio, image, gallery, radio, checkbox, gallery, gallery, checkbox, radio, radio, checkbox, checkbox, radio, image, gallery, number, checkbox, gallery)
Please also give me output for other extensions as well, i.e. do not delete anything, send me the full output
I meet the same issue
I switched to a fresh new environment and was not able to reproduce the problem with
python: 3.8.10 • torch: 2.0.0+cu118 • xformers: 0.0.17 • gradio: 3.28.1 • commit: 5ab7f213 • checkpoint: 0f0eaaa61e
This setting will also not create any problem.
python: 3.10.6 • torch: 2.0.1+cu117 • xformers: 0.0.17 • gradio: 3.28.1 • commit: 5ab7f213 • checkpoint: 0f0eaaa61e
Please let me know what other extensions you have installed. If you have only installed ControlNet, SAM, you should not see this problem. Other popular extensions like multidiffusion-upscaler, posex, cutoff, should also be compatible with ControlNet and SAM.
I have tested a lot of combinations, but none of them can really reproduce your error. Also, it is very surprising to me that people begin to create such error at this moment, instead of like 1-2 months ago. I will be on-leave for approximately a week, starting from 10 hours later. If this problem is not resolved at that time, it will be postponded to next week, approximately Wednesday or Thursday. I will still be able to monitor issues and pull requests, so if someone in the community shoot a PR, the fix process could be significantly faster.
Hello everyone here, I am not sure if this could work, but please insert a1111 to the front of the extension directory name, i.e. sd-webui-segment-anything to a1111-sd-webui-segment-anything and see what’s going on.
a1111
sorry, I was on vacation last week and just saw the message. I tried it out and it does work.3Q very much. You work is very useful.
Hello everyone here, I am not sure if this could work, but please insert a1111 to the front of the extension directory name, i.e. sd-webui-segment-anything to a1111-sd-webui-segment-anything and see what’s going on.
solved my problem
大家好,我不确定这是否有效,但请扩展目录名称的前面插入a1111,即sd-webui-segment-anything到a1111-sd-webui-segment-anything,看看发生了什么。
Hello everyone here, I am not sure if this could work, but please insert a1111 to the front of the extension directory name, i.e. sd-webui-segment-anything to a1111-sd-webui-segment-anything and see what’s going on.
It's really useful. It's great.
@continue-revolution
I guess I found the reasong (one whole night of testing).
This error: AttributeError: 'NoneType' object has no attribute 'mode'.
Reason: user didn't upload an image and mask & also the ""option" do not really copy original pic and mask to inpaint upload or controll net.
Current solution would be case C or D for now.
Final solution would be bug fixing.
Testing Procedure
Original pic is pic1
CaseA
1.in img2img, do sam, select "Copy to Inpaint Upload & img2img ControlNet Inpainting"
2. switch to inpaint upload
3. upload nothing( no picture nor mask pic)
4. in prompt type "red moon" and click generate
5. AttributeError: 'NoneType' object has no attribute 'mode'
Case B
1&2same
3. upload original pic do not upload the mask pic and believing sam extension will help me with the mask pic copied
4. same
5. no error but not working well , the inpaint work more like txt2img(pic 2)
Guess: the mask is not uploaded(copied, which mean the "Copy to Inpaint Upload & img2img ControlNet Inpainting" does not work)
Case C
1&2 same
3. upload original from folder and mask from SAM extension result
4. same
5. work well at least the inpaint area is correct(pic 3)
Case D
same as Case C, except control net is enabled and original pic is uploaded to control net.
Result in pic 4 with red moon
@JumpIntoCoding Normally this error is because you did not do https://github.com/continue-revolution/sd-webui-segment-anything#single-image item 8. A lot of people came across this error before.
@continue-revolution
same error with item 8 checked
AttributeError: 'NoneType' object has no attribute 'mode'
@JumpIntoCoding I am not able to reproduce your problem, and this error is different from the problems above in this issue. You can record your screen for the whole process you encountered this issue. If you choose to do so, please show your terminal at the end of your video, or screenshot your terminal.
*** Error running before_process: D:\tools\AI\stable-diffusion-webui\extensions-builtin\extra-options-section\scripts\extra_options_section.py
Traceback (most recent call last):
File "D:\tools\AI\stable-diffusion-webui\modules\scripts.py", line 466, in before_process
script.before_process(p, *script_args)
File "D:\tools\AI\stable-diffusion-webui\extensions-builtin\extra-options-section\scripts\extra_options_section.py", line 40, in before_process
for name, value in zip(self.setting_names, args):
TypeError: 'NoneType' object is not iterable
2023-07-02 02:04:35,858 - ControlNet - WARNING - No ControlNetUnit detected in args. It is very likely that you are having an extension conflict.Here are args received by ControlNet: ().
*** Error running process: D:\tools\AI\stable-diffusion-webui\extensions\a1111-sd-webui-segment-anything\scripts\sam.py
Traceback (most recent call last):
File "D:\tools\AI\stable-diffusion-webui\modules\scripts.py", line 474, in process
script.process(p, *script_args)
File "D:\tools\AI\stable-diffusion-webui\extensions\a1111-sd-webui-segment-anything\scripts\sam.py", line 785, in process
process_unit = SAMProcessUnit(args, is_img2img)
File "D:\tools\AI\stable-diffusion-webui\extensions\a1111-sd-webui-segment-anything\scripts\process_params.py", line 63, in init
self.sam_inpaint_unit = SAMInpaintUnit(args, is_img2img)
File "D:\tools\AI\stable-diffusion-webui\extensions\a1111-sd-webui-segment-anything\scripts\process_params.py", line 25, in init
self.init_sam_single_image_process(args)
File "D:\tools\AI\stable-diffusion-webui\extensions\a1111-sd-webui-segment-anything\scripts\process_params.py", line 29, in init_sam_single_image_process
self.inpaint_upload_enable = args[0]
IndexError: tuple index out of range
2023-07-02 02:04:35,860 - ControlNet - WARNING - No ControlNetUnit detected in args. It is very likely that you are having an extension conflict.Here are args received by ControlNet: ().
*** Error completing request
*** Arguments: ('task(6mpf4b2jk5quz20)', 4, 'huge red moon', '', [], None, None, None, None, None, None, None, 20, 0, 4, 0, 1, False, False, 1, 1, 7, 1.5, 0.75, -1.0, -1.0, 0, 0, 0, False, 0, 504, 1094, 1, 0, 1, 32, 0, '', '', '', [], 0, True, False, 0, <PIL.Image.Image image mode=RGBA size=1094x504 at 0x1A9BA277E50>, [{'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmp7n5rlu23.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmp7n5rlu23.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmpzjh9en_9.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmpzjh9en_9.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmpad04i5pn.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmpad04i5pn.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmpwcvl0feh.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmpwcvl0feh.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmprtxmub0q.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmprtxmub0q.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmps193i68h.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmps193i68h.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmpk0_bhl8r.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmpk0_bhl8r.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmplt7k_4vh.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmplt7k_4vh.png', 'is_file': True}, {'name': 'C:\Users\Kensi\AppData\Local\Temp\gradio\tmp7g3zt495.png', 'data': 'http://127.0.0.1:7860/file=C:\Users\Kensi\AppData\Local\Temp\gradio\tmp7g3zt495.png', 'is_file': True}], 0, False, [], [], False, 0, 1, False, False, 0, None, [], -2, False, [], False, 0, None, None, False, '', 0, <scripts.controlnet_ui.controlnet_ui_group.UiControlNetUnit object at 0x000001A9BA274A60>, '
- \n
CFG Scale
should be 2 or lower. \n
Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8
', 128, 8, ['left', 'right', 'up', 'down'], 1, 0.05, 128, 4, 0, ['left', 'right', 'up', 'down'], False, False, 'positive', 'comma', 0, False, False, '', 'Will upscale the image by the selected scale factor; use width and height sliders to set tile size
', 64, 0, 2, 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, [], True, True, True, 0.0, 0, None, 'gif', False, None, None, False, 50) {}Traceback (most recent call last):
File "D:\tools\AI\stable-diffusion-webui\modules\call_queue.py", line 55, in f
res = list(func(*args, **kwargs))
File "D:\tools\AI\stable-diffusion-webui\modules\call_queue.py", line 35, in f
res = func(*args, **kwargs)
File "D:\tools\AI\stable-diffusion-webui\modules\img2img.py", line 198, in img2img
processed = process_images(p)
File "D:\tools\AI\stable-diffusion-webui\modules\processing.py", line 620, in process_images
res = process_images_inner(p)
File "D:\tools\AI\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 42, in processing_process_images_hijack
return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
File "D:\tools\AI\stable-diffusion-webui\modules\processing.py", line 680, in process_images_inner
p.init(p.all_prompts, p.all_seeds, p.all_subseeds)
File "D:\tools\AI\stable-diffusion-webui\modules\processing.py", line 1239, in init
image = images.flatten(img, opts.img2img_background_color)
File "D:\tools\AI\stable-diffusion-webui\modules\images.py", line 725, in flatten
if img.mode == "RGBA":
AttributeError: 'NoneType' object has no attribute 'mode'
Try #93 (comment)
Again, the reason why there is an extension conflict is that you are using a certain extension other than ControlNet and SAM. There is no good way at this moment to fix this issue from code level.
- In settings, select ControlNet and check "Allow other script to control this extension", and also uncheck the
SD-CN-Animation
plug-in. - As shown in the figure below.
- It is also mentioned in the official website:
https://github.com/continue-revolution/sd-webui-segment-anything#single-image
item 8. [VERY IMPORTANT] Update your ControlNet and check Allow other script to control this extension (MUST) on your ControlNet settings.