An Image utils extension for A1111's sd-webui
Features:
- blending (support 17 mode)
- color adjust
- tone curve
- blur
- img2sketch(thourgh XDoG)
- pixelize(Kmeans or dithering)
- glow (blur and blend)
- inoutpaint support tool
An Image utils extension for A1111's sd-webui
License: Apache License 2.0
An Image utils extension for A1111's sd-webui
Features:
sometimes it would be cool to generate some things and turn them upside down since stable diffusion doesn't do sideways or upside orientations very easily.
Please, add feature "Set size X/Y aligning to top/left/right/bottom", upscaling/downscaling image (no fancy stuff, PIL resize) to fit final size. This tab useful for preparing image for inpaint and there is no point in calculating exact values in that case
Tnx for the tool!
Sometimes when changing image size with fill left/right there python error in console
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/gradio/routes.py", line 394, in run_predict
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1075, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 884, in call_function
prediction = await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 867, in run
result = context.run(func, *args)
File "/content/stable-diffusion-webui/extensions/a1111-sd-webui-haku-img/inoutpaint/main.py", line 20, in run
new_img, mask = resize_with_mask(
File "/content/stable-diffusion-webui/extensions/a1111-sd-webui-haku-img/inoutpaint/utils.py", line 15, in resize_with_mask
new_img = Image.new('RGB', (w+l+r, h+u+d))
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
If i change values a bit - error gone
Thanks for useful tool!
i found that if i put another image into it, the same settings are leftover from the last image. it'd be cool if there was a way to reset them back to default. would help if you messed up a setting and forgot which one, without refreshing the browser.
Error loading script: main.py
Traceback (most recent call last):
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/scripts.py", line 205, in load_scripts
module = script_loading.load_module(scriptfile.path)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/script_loading.py", line 13, in load_module
exec(compiled, module.dict)
File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/extensions/a1111-sd-webui-haku-img/scripts/main.py", line 24, in
all_btns: list[tuple[gr.Button, ...]] = []
TypeError: 'type' object is not subscriptable
Help .-., I'm using TheLastBen WebUI & didn't know what caused it. It happened after the extension was installed and tried to restart the WebUI.
Thank you!
please brother, consider adding a "SAVE" button to allow save in the selected folder according to Auto1111 settings and image format settings. I'm using this beautiful extention everyday but i'm always forced to send the image to img1img module, denoise 0 and then save again, to allow actual save to jpg/png, also with metadata.
Traceback (most recent call last):
File "D:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
output = await app.get_blocks().process_api(
File "D:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1015, in process_api
result = await self.call_function(
File "D:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 833, in call_function
prediction = await anyio.to_thread.run_sync(
File "D:\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "D:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "D:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 867, in run
result = context.run(func, *args)
File "D:\stable-diffusion-webui\extensions\a1111-sd-webui-haku-img\hakuimg\sketch.py", line 38, in run
return xdog(*args)
File "D:\stable-diffusion-webui\extensions\a1111-sd-webui-haku-img\hakuimg\sketch.py", line 24, in xdog
dog = dog_filter(img, kernel, sigma, k_sigma, gamma)
File "D:\stable-diffusion-webui\extensions\a1111-sd-webui-haku-img\hakuimg\sketch.py", line 15, in dog_filter
g1 = gaussian(img, kernel, sigma)
File "D:\stable-diffusion-webui\extensions\a1111-sd-webui-haku-img\hakuimg\sketch.py", line 11, in gaussian
return cv2.GaussianBlur(img, (kernel, kernel), sigma)
cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\smooth.dispatch.cpp:294: error: (-215:Assertion failed) ksize.width > 0 && ksize.width % 2 == 1 && ksize.height > 0 && ksize.height % 2 == 1 in function 'cv::createGaussianKernels'
super cool
Error loading script: main.py
Traceback (most recent call last):
File "/content/stable-diffusion-webui/modules/scripts.py", line 205, in load_scripts
module = script_loading.load_module(scriptfile.path)
File "/content/stable-diffusion-webui/modules/script_loading.py", line 13, in load_module
exec(compiled, module.dict)
File "/content/stable-diffusion-webui/extensions/a1111-sd-webui-haku-img/scripts/main.py", line 12, in
from hakuimg import(
File "/content/stable-diffusion-webui/extensions/a1111-sd-webui-haku-img/hakuimg/pixel.py", line 88, in
) -> tuple[NDArray[Any], NDArray[Any]]:
TypeError: 'type' object is not subscriptable
a1111-sd-webui-haku-img/scripts/main.py
Line 114 in 5069e2b
Hello,
currently this extensions uses features that are available only in Python 3.10 (such as | for typing).
This leaves out a chunk of cloud users (Colab and Paperspace) which use 3.8 and 3.9, respectively.
This traceback is produced on startup (from Paperspace, which uses 3.9):
Error executing callback ui_tabs_callback for /notebooks/stable-diffusion-webui/extensions/a1111-sd-webui-haku-img/scripts/main.py
Traceback (most recent call last):
File "/notebooks/stable-diffusion-webui/modules/script_callbacks.py", line 106, in ui_tabs_callback
res += c.callback() or []
File "/notebooks/stable-diffusion-webui/extensions/a1111-sd-webui-haku-img/scripts/main.py", line 211, in add_tab
component.change(pixel.run, all_p_input, image_out)
File "/usr/local/lib/python3.9/dist-packages/gradio/events.py", line 81, in change
dep = self.set_event_trigger(
File "/usr/local/lib/python3.9/dist-packages/gradio/blocks.py", line 190, in set_event_trigger
check_function_inputs_match(fn, inputs, inputs_as_dict)
File "/usr/local/lib/python3.9/dist-packages/gradio/utils.py", line 787, in check_function_inputs_match
parameter_types = typing.get_type_hints(fn) if inspect.isfunction(fn) else {}
File "/usr/lib/python3.9/typing.py", line 1497, in get_type_hints
value = _eval_type(value, globalns, localns)
File "/usr/lib/python3.9/typing.py", line 292, in _eval_type
return t._evaluate(globalns, localns, recursive_guard)
File "/usr/lib/python3.9/typing.py", line 554, in _evaluate
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
TypeError: unsupported operand type(s) for |: 'type' and 'type'
Does it let you blend without the mask parts?
from PIL import ImageEnhance, Image
import numpy as np
def get_exposure_offset(img, value, brightness_value):
if value <= 0:
return img
np_img = np.array(img).astype(float) + value * 75
np_img = np.clip(np_img, 0, 255).astype(np.uint8)
img = Image.fromarray(np_img)
return ImageEnhance.Brightness(img).enhance(
(brightness_value+1) - value / 4
)
import cv2
import numpy as np
from PIL import ImageFilter, ImageChops, Image, ImageOps, ImageEnhance
from blendmodes.blend import blendLayers, BlendType
def get_hdr(img, value, original_img):
if value <= 0:
return img
blurred = img.filter(ImageFilter.GaussianBlur(radius=2.8))
difference = ImageChops.difference(img, blurred)
sharp_edges = Image.blend(img, difference, 1)
converted_original_img = (
np.array(original_img)[:, :, ::-1].copy().astype("float32") / 255.0
)
converted_sharped = (
np.array(sharp_edges)[:, :, ::-1].copy().astype("float32") / 255.0
)
color_dodge = converted_original_img / (1 - converted_sharped)
converted_color_dodge = (255 * color_dodge).clip(0, 255).astype(np.uint8)
temp_img = Image.fromarray(
cv2.cvtColor(converted_color_dodge, cv2.COLOR_BGR2RGB)
)
inverted_color_dodge = ImageOps.invert(temp_img)
black_white_color_dodge = ImageEnhance.Color(inverted_color_dodge).enhance(0)
hue = blendLayers(temp_img, black_white_color_dodge, BlendType.HUE)
hdrImage = blendLayers(hue, temp_img, BlendType.NORMAL, 0.7)
return blendLayers(img, hdrImage, BlendType.NORMAL, value * 2).convert(
"RGB"
)
from PIL import ImageChops, Image
import numpy as np
def get_noise(img, value):
if value <= 0:
return img
noise_value = np.random.randint(0, value * 100, img.size, np.uint8)
noise_img = Image.fromarray(noise_value, "L").resize(img.size).convert(img.mode)
return ImageChops.add(img, noise_img)
from PIL import ImageEnhance
def get_sharpness(img, value):
if value <= 0:
return img
return ImageEnhance.Sharpness(img).enhance((value+1) * 1.5)
from PIL import ImageDraw, Image, ImageFilter
def get_vignette(img, value):
if value <= 0:
return img
width, height = img.size
mask = Image.new("L", (width, height), 0)
draw = ImageDraw.Draw(mask)
padding = 100 - value * 100
draw.ellipse(
(-padding, -padding, width + padding, height + padding), fill=255
)
mask = mask.filter(ImageFilter.GaussianBlur(radius=100))
return Image.composite(img, Image.new("RGB", img.size, "black"), mask)
So there is a cool chromatic effect: https://github.com/yoonsikp/kromo/tree/master
I think it's more convenient, because the picture is not created many times when you move the slider, but is created only when you release it
executing callback: D:\automatic\extensions\a1111-sd-webui-haku-img\scripts\main.py ui_tabs_callback: UnboundLocalError
┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ D:\automatic\modules\script_callbacks.py:142 in ui_tabs_callback │
│ │
│ 141 │ │ try: │
│ > 142 │ │ │ res += c.callback() or [] │
│ 143 │ │ except Exception as e: │
│ │
│ D:\automatic\extensions\a1111-sd-webui-haku-img\scripts\main.py:314 in add_tab │
│ │
│ 313 │ │ gpc.bind_buttons(send_btns, image_out, None) │
│ > 314 │ │ for btn, img in zip(btns, all_layers): │
│ 315 │ │ │ btn.click(lambda x:x, image_out, img) │
└─────────────────────────────────────────────────────────────
UnboundLocalError: local variable 'btns' referenced before assignment
so for instance, if i want to put a shirt on someone, I could line up the shirt with the person's body, with resizing and centering.
Traceback (most recent call last):
File "D:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
output = await app.get_blocks().process_api(
File "D:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1015, in process_api
result = await self.call_function(
File "D:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 833, in call_function
prediction = await anyio.to_thread.run_sync(
File "D:\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "D:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "D:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 867, in run
result = context.run(func, *args)
File "D:\stable-diffusion-webui\extensions\a1111-sd-webui-haku-img\hakuimg\blend.py", line 98, in blend
for alpha, mask_blur, mask_str, mode, img in reversed(zip(*chunks)):
TypeError: 'zip' object is not reversible
maybe its unrelated, not sure. the preview window to the right gets an error box and shows no images
Traceback (most recent call last):
File "E:\ai\stable-diffusion-webui\modules\scripts.py", line 195, in load_scripts
module = script_loading.load_module(scriptfile.path)
File "E:\ai\stable-diffusion-webui\modules\script_loading.py", line 13, in load_module
exec(compiled, module.dict)
File "E:\ai\stable-diffusion-webui\extensions\a1111-sd-webui-haku-img\scripts\main.py", line 7, in
from modules.ui_components import FormRow
ModuleNotFoundError: No module named 'modules.ui_components'
I checked the other repo which is marked as "read this", my python version isn't the problem according to me as its already 3.10.9, and venv is using that.
If I want to check what is on a layer I have to go to all layers above it and turn down their opacity. Unless I am missing something, this seems like a really long way to do things.
Is there a way to isolate layers more quickly? Perhaps a check on/off for each layer? Maybe even a quick way re-order them.
I can see how this could be the most useful and creative extension of auto111. Finally, a way to bash countless variations is genius, but presently I get so confused trying to work out what order I should be masking while remembering what's on each layer. I end up randomly clicking and sliding out of frustration.
I've watched your videos a ton but I just can't work it out so my best hope is a you-tuber does an in-depth explainer on this amazing ext.
There's been a ton of updates since I last tried this so I have no doubts about where it's heading. it's setting up to be pretty awesome. Well done, keep up; the good work
Hello. I'm leaving a comment as you seem to be accepting feature requests.
Is it possible to specify the blur location (blur only the background) with a depth map mask?
(create depth map from one image)
https://github.com/isl-org/MiDaS
https://huggingface.co/spaces/pytorch/MiDaS
If you can do this, the quality of the generated image for live action will be greatly improved
I'm a programming novice, so I'm not sure if it can actually be implemented, but I'd appreciate it if you could check it out.
As title says i remember reading that SD upgraded gradio and im getting this error after updating
"
add tab
*** Error executing callback ui_tabs_callback for C:\Users\Anton\Downloads\stable-diffusion-webui-forge\extensions\a1111-sd-webui-haku-img\scripts\main.py
Traceback (most recent call last):
File "C:\Users\Anton\Downloads\stable-diffusion-webui-forge\modules\script_callbacks.py", line 283, in ui_tabs_callback
res += c.callback() or []
File "C:\Users\Anton\Downloads\stable-diffusion-webui-forge\extensions\a1111-sd-webui-haku-img\scripts\main.py", line 456, in add_tab
_release_if_possible(
File "C:\Users\Anton\Downloads\stable-diffusion-webui-forge\extensions\a1111-sd-webui-haku-img\scripts\main.py", line 635, in _release_if_possible
if isinstance(component, gr.events.Releaseable):
AttributeError: module 'gradio.events' has no attribute 'Releaseable'
"
is there anything i can do to make it work again?
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.