Giter Club home page Giter Club logo

multi-subject-render's Introduction

multi-subject-render

Generate multiple complex subjects all at once!

Made as a script for the AUTOMATIC1111/stable-diffusion-webui repository.

00165-603508287-DDIM-64-7 5-ac07d41f-20221122154627

Miaouuuuuuuuu!

Jump to examples!

๐Ÿ’ฅ Installation ๐Ÿ’ฅ

Copy the url of that repository into the extension tab :

image

OR copy that repository in your extension folder :

image

You might need to restart the whole UI. Maybe twice.

The look

image

OK I know that's a big screenshot

How the hell does this works?

First it creates your background image, then your foreground subjects, then does a depth analysis on them, cut their backgrounds, paste them onto your background and then does an img2img for a smooth blend!

It will cut around that lady with scissors made of code.

image

Explanations of the different UI elements

I will only explain the not so obvious things because I spent enough time making that thing already.

  • First off, your usual UI will be for your initial background. So your normal prompt will probably be something like "a beach, sunny sky" etc.

For my example I decided to generate a bowling alley at 512x512 pixels :

00158-2629831387-Euler a-22-7 5-ac07d41f-1233221312123132

  • Your foreground subjects will be described in that text box.
  • You case use wildcards.
  • If you only use the first line, that line will be used for every foreground subject that will be generated.
  • If you use multiple lines, each line will be used for each foreground subject.
  • The negative prompt is carried over everything

image

Note : if you do that, you will need as many lines as foreground images generated.

For my example I made tree penguins :

sdffsdsdfsdffsddsfsfd

  • That's how much the seed will be incremented at each image. If you set it to 0 you will get the same foregrounds every time. Probably not what you want unless you use the Extra option in your main UI and "Variation strength".

image

  • You can use a different sampler for the foregrounds. As well as a different CLIP value.

image

  • The final blend is there to either make a smooth pass over your collage or to make something more complex / add details to your combination.
  • You can use different settings and samplers for your final blend. Make as you wish. The CLIP value will be the one you've set in your settings tab. Not the one for the foregrounds. So you can decide if you prefer one way or the other.

00162-2629838387-Euler a-92-7 5-ac07d41f-20221124054727

The are not really playing bowling because you need fingers. They're just here for trouble.

  • An important part is to set the final blend width. Your initial background will be stretched to that size so you don't really need to make it initially big. Your foregrounds subjects will be pasted onto your stretched background before the final blend. Not wide enough and you will end up having too many characters at the same spot.

image

The scary miscellaneous options :

  • The foreground distance from center multiplier will make your characters closer together if you select a lower value, further with a higher one. I usually stick in between 0.8 and 1.0

  • Foreground Y shift : the center character will always be at the same height. The you multiply the value of that slider by the position of the foreground subject from the center. That gives you how many pixels lower they will be. Think about some super hero movie poster with the sidies slightly lower. That's what this slider does.

  • Foreground depth cut treshold is the scary one. At 0 the backgrounds of your foregrounds subjects will be opaque. At 255 the entire foreground will be transparent. The best values are in between 50-60 for cartoon-like characters and 90-100 for photorealistic subjects. Too much and they lose their heads, not enough and you get some rock that were sitting on in your final blend.

  • Random superposition : the default is to have the center character in front. if you enable that it might not be the case anymore. That's a cool option depending on what you want to do.

  • The center character will be behind the others. If you use the previous option this one becomes useless.

  • face correction is only for the final blend. If you want that on every foreground subjects, set it in your main UI. It think it's best to enable both if you make photorealistic stuff.

image

Tips and tricks :

  • using (bokeh) and (F1.8:1.2) will make blurry backgrounds which will make it easier for the depth analysis to do a clean cut of the backgrounds.
  • "wide angle" in your prompt will give your more chances to have characters that won't be cropped
  • "skin details" or "detailed skin" raises the chances of having close-ups. I prefer to avoid.
  • Not enough denoising/steps on your final blend will make it look like you used scissors on your moms Vogue catalogue and pasted the ladies onto your dads Lord of the Rings favorite poster. Don't do that.
  • Too much denoising/steps might make the characters all look the same. It's all about finding the right middle value for your needs.
  • Making your foreground subjects have less height than the final image might make them look cropped.
  • You can now use the "Mask foregrounds in blend" checkbox to get something that looks more like a collage and use this in img2img with my other extension if you want your foreground subjects to be less alterated by the img2img blend.

Known issues

  • It does only render the final blend to the UI. You have to save the images (like in the settings you just don't uncheck that "save all images" checkbox and you're good).
  • "List index out of range" might be barfed into your terminal if you interrupt a generation. I missed a state interrupt somewhere. It does not cause any problem by itself.
  • Do not use the "high res fix" checkbox. The blend size slider at the end will trigger it if you use a higher resolution than your background image. So keep your normal UI size sliders near 512*512.
  • There can be bugs.
  • AttributeError: 'StableDiffusionProcessingTxt2Img' object has no attribute 'sampler_name' : You need to update your webui ("git pull" in a commandline from your webui folder)
  • Do check the other issues before opening a new one and try to give as many details as possible.
  • Use the discussion tab if it's not about a bug.
  • Make sure to run the latest webui version by doing "git pull" from your webui folder!

Credits

Thanks to thygate for letting me blatantly copy-paste some of his functions for the depth analysis integration in the webui.

This repository runs with MiDaS.

@ARTICLE {Ranftl2022,
    author  = "Ren\'{e} Ranftl and Katrin Lasinger and David Hafner and Konrad Schindler and Vladlen Koltun",
    title   = "Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-Shot Cross-Dataset Transfer",
    journal = "IEEE Transactions on Pattern Analysis and Machine Intelligence",
    year    = "2022",
    volume  = "44",
    number  = "3"
}
@article{Ranftl2021,
	author    = {Ren\'{e} Ranftl and Alexey Bochkovskiy and Vladlen Koltun},
	title     = {Vision Transformers for Dense Prediction},
	journal   = {ICCV},
	year      = {2021},
}

A few more examples

An attempt at recreating the "Distracted boyfriend" meme. Without influencing the directions in which they are looking. 100% txt2img.

00241-2439212203-Euler a-100-7 5-ac07d41f-20221124151538 00287-2439212203-Euler a-100-7 5-ac07d41f-20221124151832 00123-60606195-DDIM-74-7 5-ac07d41f-20221124144302 00133-1894928239-DDIM-74-7 5-ac07d41f-20221124144525

I messed up the order on the last one.

00129-603508287-DDIM-64-7 5-ac07d41f-20221122153921

Aren't they cute without oxygen?

00051-3908280031-DPM++ 2M-74-7 5-ac07d41f-20221122145842

Of course you can make a harem just for yourself.

00165-603508287-DDIM-64-7 5-ac07d41f-20221122154627

MOAR KITTENS

Now a few more groups of "super heroes" from the same batch as the first image here. Except maybe for the portraits.

00290-1347027509-DDIM-69-7 5-579c005f-20221123193425

Wrong settings examples

00145-2998285171-DDIM-92-7 5-ac07d41f-20221124054225

This is what too low denoising on the final blend looks like. Yuk!

00254-1268283421-Euler a-68-7 5-ac07d41f-20221124060832

Same issue here. Looks like a funny kid collage. Grandma will love it because you typed your prompts with love and she knows it.

multi-subject-render's People

Contributors

extraltodeus avatar kamilowaty122 avatar martok88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multi-subject-render's Issues

Flipping characters

Please add image flipping so it would be possible to can change direction where characters are facing, when they all facing in a single direction all the time. Often adding to the prompt 'facing right' doesn't help at all, and switching the direction would be very helpful.

UnboundLocalError: local variable 'model' referenced before assignment error when internet is turned off?

When I have no internet I get this error. UnboundLocalError: local variable 'model' referenced before assignment

Any easy way to fix this? I also know nothing about coding so maybe this is obvious

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users#\stable-diffusion-webui\modules\ui.py", line 185, in f
res = list(func(*args, **kwargs))
File "C:\Users#\stable-diffusion-webui\webui.py", line 57, in f
res = func(*args, **kwargs)
File "C:\Users#\stable-diffusion-webui\modules\txt2img.py", line 46, in txt2img
processed = modules.scripts.scripts_txt2img.run(p, *args)
File "C:\Users#\stable-diffusion-webui\modules\scripts.py", line 317, in run
processed = script.run(p, *script_args)
File "C:\Users#\stable-diffusion-webui\extensions\multi-subject-render\scripts\multirender.py", line 244, in run
foreground_image_mask = sdmg.calculate_depth_map_for_waifus(foreground_image)
File "C:\Users#\stable-diffusion-webui\extensions/multi-subject-render/scripts/simple_depthmap.py", line 130, in calculate_depth_map_for_waifus
del model
UnboundLocalError: local variable 'model' referenced before assignment

this is what ive got

AttributeError: 'StableDiffusionProcessingTxt2Img' object has no attribute 'sampler_name'

Sorry if this isn't an issue with your code directly. The process keeps getting interrupted with this error. I've used SD quite a bit by now, never seen it before. Am I using the wrong ckpt perhaps?

Traceback (most recent call last): File "C:\Users\***\stable-diffusion-webui\modules\ui.py", line 185, in f res = list(func(*args, **kwargs))

File "C:\Users\***\stable-diffusion-webui\webui.py", line 56, in f res = func(*args, **kwargs)

File "C:\Users\***\stable-diffusion-webui\modules\txt2img.py", line 45, in txt2img processed = modules.scripts.scripts_txt2img.run(p, *args)

File "C:\Users\***\stable-diffusion-webui\modules\scripts.py", line 297, in run processed = script.run(p, *script_args)

File "C:\Users\***\stable-diffusion-webui\extensions\multi-subject-render\scripts\multirender.py", line 167, in run o_sampler_name = p.sampler_name

ModuleNotFoundError: No module named 'repositories.midas'

image
ไปŠๅคฉๅˆšๅˆš่ฃ…ไธŠ๏ผŒ็‚นๅ‡ป็”ŸๆˆๅŽๅฐฑๅ‡บ็Žฐ่ฟ™ไธช๏ผŒไธ็Ÿฅ้“ๆ˜ฏไธๆ˜ฏๅ’Œๆ–ฐ็‰ˆ็š„webuiไธๅ…ผๅฎน

IndexError: list index out of range

Error message:

Loading midas model weights ..
./models/midas/midas_v21_small-70d6b9c8.pt
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 40/40 [00:05<00:00,  7.36it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 24/24 [00:03<00:00,  7.53it/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 24/24 [00:03<00:00,  7.59it/s]
Error completing request6:39,  8.24it/s]
Arguments: ('Background in 2DLyoko style', '', 'None', 'None', 40, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, 0.7, 0, 0, 4, 0.9, 5, '0.0001', False, 'None', '', 0.1, False, False, False, False, '', 1, '', 0, '', True, False, False, 'Aelita2D standing with smile on face, (bokeh), (F1.8:1.2)\nJeremy2D standing looking at camera, (bokeh), (F1.8:1.2)', 5, 24, 12.5, 1000, 'Euler a', 0, 64, 64, '', 64, 7.5, 0.42, 'Euler a', 1600, 64, 1, 0, 92, True, True, True, False, False, '{inspiration}', None) {}
Traceback (most recent call last):
  File "I:\stable-diffusion-webui\modules\ui.py", line 185, in f
    res = list(func(*args, **kwargs))
  File "I:\stable-diffusion-webui\webui.py", line 57, in f
    res = func(*args, **kwargs)
  File "I:\stable-diffusion-webui\modules\txt2img.py", line 46, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "I:\stable-diffusion-webui\modules\scripts.py", line 317, in run
    processed = script.run(p, *script_args)
  File "I:\stable-diffusion-webui\extensions\multi-subject-render\scripts\multirender.py", line 203, in run
    p.prompt    = foregen_prompts[i] if len(foregen_prompts) > 1 else foregen_prompt
IndexError: list index out of range

List index out of range

When running any settings with the script I get a "list index out of range" error and no output is created

Stable diffusion version: python: 3.7.13 โ€€โ€ขโ€€ torch: 1.13.0+rocm5.2 โ€€โ€ขโ€€ xformers: N/A โ€€โ€ขโ€€ gradio: 3.15.0 โ€€โ€ขโ€€ commit: 4cc02ec7

Running in docker on linux, with AMD Rx5700XT card.

Multi-subject render updated today Jan 12

Settings used:

Everything default with the background prompt "lake". In the subject field three lines with "man" "woman" "dog" respectively. In the final prompt "woman and a man with their dog at a lake".

Console output:

+ python -u launch.py --api --medvram --no-half --precision=full --listen --enable-insecure-extension-access --opt-split-attention
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 20/20 [00:09<00:00,  2.21it/s]
DDIM Sampler: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 25/25 [00:11<00:00,  2.12it/s]
DDIM Sampler: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 25/25 [00:07<00:00,  3.19it/s]
DDIM Sampler: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 25/25 [00:07<00:00,  3.18it/s]
Error completing request
Arguments: ('lake ', '', 'None', 'None', 20, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, 0.7, 2, 'Latent', 0, 0, 0, 4, 0.9, 5, '0.0001', False, 'None', '', 0.1, False, False, False, False, False, '', 1, '', 0, '', True, False, False, 'woman\nman\ndog', 5, 24, 12.5, 1000, 'DDIM', 0, 64, 64, 'woman and a man with their dog at a lake', 64, 7.5, 0.42, 'DDIM', 64, 64, 1, 0, 92, True, True, True, False, False, False, 'midas_v21_small') {}
Traceback (most recent call last):
  File "/dockerx/stable-diffusion-webui/modules/call_queue.py", line 45, in f
    res = list(func(*args, **kwargs))
  File "/dockerx/stable-diffusion-webui/modules/call_queue.py", line 28, in f
    res = func(*args, **kwargs)
  File "/dockerx/stable-diffusion-webui/modules/txt2img.py", line 49, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "/dockerx/stable-diffusion-webui/modules/scripts.py", line 337, in run
    processed = script.run(p, *script_args)
  File "/dockerx/stable-diffusion-webui/extensions/multi-subject-render/scripts/multirender.py", line 231, in run
    p.prompt    = foregen_prompts[i] if len(foregen_prompts) > 1 else foregen_prompt
IndexError: list index out of range

Memory Leak

The extension isn't freeing up V-RAM properly.
I lose a little over 2GB every time I generate an Image until its completely filled up and I'm forced to restart the webui.

RuntimeError: CUDA out of memory. Tried to allocate 366.00 MiB (GPU 0; 8.00 GiB total capacity; 5.63 GiB already allocated; 0 bytes free; 6.95 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Error verifying pickled file

Error verifying pickled file from C:\Users\hunte\stable-diffusion-webui\models\Codeformer\codeformer-v0.1.0.pth:
Traceback (most recent call last):
File "C:\Users\hunte\stable-diffusion-webui\modules\safe.py", line 81, in check_pt
with zipfile.ZipFile(filename) as z:
File "C:\Users\hunte\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1267, in init
self._RealGetContents()
File "C:\Users\hunte\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1334, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

[Feature request] Foreground X shift and zoom

I like your extension, but I'm missing one option: the X shift of the foreground, which would allow me to place it in a perfect position on the image without enlarging the background image.
(Unfortunately the Y shift doesn't work for me with one subject on the cropped image either, please check that too!)
It would also be nice if I could zoom in-out the foreground image instead of zooming in the background image (because I can only zoom in the background image up to a certain size because of the video card). Like a Z vector/parameter. A random zoom would also enhance the collage.

Thanks in advance if you can make it work!

Error loading script: depthmap.py

I cannot run the script because I get a loading script error involving depthmap.py.

In the final line of the console, it lists "FileNotFoundError: [Errno 2] No such file or directory: './externals/Next_ViT/classification/nextvit.py'" as the specific error in question.

Not sure how to fix it, as a Google search doesn't turn up any similar results.

no module 'timm.models.beit'

Launching Web UI with arguments: --enable-insecure-extension-access --share --gradio-debug --medvram --disable-safe-unpickle --xformers
A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named 'triton'
Error loading script: simple_depthmap.py
Traceback (most recent call last):
File "/content/stable-diffusion-webui/modules/scripts.py", line 195, 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/multi-subject-render/scripts/simple_depthmap.py", line 11, in
from repositories.midas.midas.dpt_depth import DPTDepthModel
File "/content/stable-diffusion-webui/repositories/midas/midas/dpt_depth.py", line 5, in
from .blocks import (
File "/content/stable-diffusion-webui/repositories/midas/midas/blocks.py", line 4, in
from .backbones.beit import (
File "/content/stable-diffusion-webui/repositories/midas/midas/backbones/beit.py", line 9, in
from timm.models.beit import gen_relative_position_index
ModuleNotFoundError: No module named 'timm.models.beit'

Error loading script: depthmap.py
Traceback (most recent call last):
File "/content/stable-diffusion-webui/modules/scripts.py", line 195, 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/stable-diffusion-webui-depthmap-script/scripts/depthmap.py", line 40, in
from midas.dpt_depth import DPTDepthModel
File "/content/stable-diffusion-webui/extensions/stable-diffusion-webui-depthmap-script/scripts/midas/dpt_depth.py", line 5, in
from .blocks import (
File "/content/stable-diffusion-webui/extensions/stable-diffusion-webui-depthmap-script/scripts/midas/blocks.py", line 4, in
from .backbones.beit import (
File "/content/stable-diffusion-webui/extensions/stable-diffusion-webui-depthmap-script/scripts/midas/backbones/beit.py", line 9, in
from timm.models.beit import gen_relative_position_index
ModuleNotFoundError: No module named 'timm.models.beit'

lighting coherence and img2img depthmask for 1.5

  1. HEy, do you know how to solve coherence with light? subjects dont really fit into the bacgkgrounds, even on your examples its daylight sun on girls but the room is lit by practical lamps ,also it doesnt hit all subjects from the same angle like it should if theyd be there together in the scene...
    How to solve this i have no idea, i think now its like copy paste from different photos to completely random bg.Works ok mostly with flat comics subjects.With realistic stuff it wont, maybe a bit with overcast lighting.
    Would be great it the code would compare light from background , the angle and use it to synthesize subjects...

2 that depth mask is great, when it will be available for regular 1.5 models trained on dreambooth? That should give people much better coherence between multiple images, cant wait for this one, would be nice if this would be separate extension or actually added into the main repo but auto1111 isnt as active nowadays., big git pull requests queue ...

Repositories Error

Hello, I followed the instructions to install from url and all of the files seem to be in the right place.

However I'm getting this error when starting the webui and the ui is not changing because of it I assume.

Any thoughts?
chrome_LToYPKCdyE

ModuleNotFoundError: No module named 'repositories.midas'

I installed the extension via the extensions tab, followed everything and I'm getting this error

I guess I only need to put midas on the repositories folder, but nothing of this is on the readme, so I wanted to write it here to check if this is the problem and should be on the readme or not, nice work!

[Feature Request] Different models for foreground and background

It would be nice to have a selection to use a different model for each part. I've managed to dreambooth and merge models that are incapable of backgrounds or incapable of humanoid subjects and it would be neat to be able to mix them which would require usage of three different models. Image attached is just a sample of my idea done quickly with inspector. If it doesn't seem to difficult I would even be willing to work on this myself and submit it when I have the time.

image

I know you said to use the Discussions if it's not about a bug but I figured in the off chance this gets implemented or I submit it that it would be good to have it tracked for when people search if it's wanted.

ModuleNotFoundError: No module named 'scripts.simple_depthmap'

Using the extention install method from URL.

Traceback (most recent call last):
  File "G:\stable-diffusion-webui\modules\ui.py", line 185, in f
    res = list(func(*args, **kwargs))
  File "G:\stable-diffusion-webui\webui.py", line 57, in f
    res = func(*args, **kwargs)
  File "G:\stable-diffusion-webui\modules\txt2img.py", line 46, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "G:\stable-diffusion-webui\modules\scripts.py", line 317, in run
    processed = script.run(p, *script_args)
  File "G:\stable-diffusion-webui\extensions\multi-subject-render\scripts\multirender.py", line 112, in run
    import scripts.simple_depthmap as sdmg
ModuleNotFoundError: No module named 'scripts.simple_depthmap'

Adding simple_depthmap.py to the root scripts folder resolves the issue.

So something up with import from an extension. (Dont know python, so cant help).

BTW this extension looks awesome!

How to achieve best result?

I might need some guidance on getting best result.

STEP 1
I understand we prompting the background. I tried 1600 x 512, but some model does not work. I ended using just 512 x 512, and it will stretch.

STEP 2
I manage to get okey result, sometimes with variation of face (if person), but STEP 3 seems to make all the faces look the same again somewhat.

STEP 3
Final step blending is the weird one, although it seems to unify everything, I tend to get low quality result. I wonder if I need to increase the steps.

When specifying 1600 x 512 in STEP 3, it works, but it took 30 minutes on Mac Mini M2 Pro.

UnboundLocalError: local variable 'model' referenced before assignment, on all models but midas_v21_small

Traceback (most recent call last):
File "G:\sd-new\modules\call_queue.py", line 45, in f
res = list(func(*args, **kwargs))
File "G:\sd-new\modules\call_queue.py", line 28, in f
res = func(*args, **kwargs)
File "G:\sd-new\modules\txt2img.py", line 49, in txt2img
processed = modules.scripts.scripts_txt2img.run(p, *args)
File "G:\sd-new\modules\scripts.py", line 337, in run
processed = script.run(p, *script_args)
File "G:\sd-new\extensions\multi-subject-render\scripts\multirender.py", line 263, in run
foreground_image_mask = sdmg.calculate_depth_map_for_waifus(foreground_image)
File "G:\sd-new\extensions/multi-subject-render/scripts/simple_depthmap.py", line 187, in calculate_depth_map_for_waifus
del model
UnboundLocalError: local variable 'model' referenced before assignment

This happens consistently when using any model except for midas_v21_small. All the models download fine, but the error happens after the foreground images are generated. midas_v21_small works fine. I saw the other issue with the same error, but that seems unrelated as my internet connection has no bearing here.

firstphase_width'

Whenever I try to use this I get an AttributeError: 'StableDiffusionProcessingTxt2Img' object has no attribute 'firstphase_width' error. I'm not very techy so I have no idea what this means or how to fix it. I tried using the default settings and also messed around trying out different settings but I always get the same error

Negative prompts

Hello, you have done a great work here, but how about implementing neg prompts for foreground and blend?

I can't find it in webui page

Admire you for such a creative idea! But I can't run it properly.....
I have already installed it correctly, and midas too. However, it is missing in my webui page, but it shows in my extension page yet. I comfirmed I have enabled it in that page. It is quite puzzling, how can I open it? No errors appear in command terminal.
terminal_page
terminal screenshot
extension_page
extension page screenshot
midas
midas already install

AttributeError: 'Block' object has no attribute 'drop_path'

Note: this may be me not knowing how to use it, please explain if needed - this is a very basic test, haven't found either how to position foreground items.

Testing extension with background + 2 foreground characters
Model: dynavisionXL, image size 832x1216
Settings:
image

After generating correctly the background and the two foreground images, preview dissapears and an error shows up instead:
"AttributeError: 'Block' object has no attribute 'drop_path' "

Traceback:

Traceback (most recent call last):
      File "F:\automatic1111\stable-diffusion-webui\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "F:\automatic1111\stable-diffusion-webui\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "F:\automatic1111\stable-diffusion-webui\modules\txt2img.py", line 52, in txt2img
        processed = modules.scripts.scripts_txt2img.run(p, *args)
      File "F:\automatic1111\stable-diffusion-webui\modules\scripts.py", line 601, in run
        processed = script.run(p, *script_args)
      File "F:\automatic1111\stable-diffusion-webui\extensions\multi-subject-render\scripts\multirender.py", line 267, in run
        foreground_image_mask = sdmg.calculate_depth_map_for_waifus(foreground_image)
      File "F:\automatic1111\stable-diffusion-webui\extensions/multi-subject-render/scripts/simple_depthmap.py", line 149, in calculate_depth_map_for_waifus
        prediction = model.forward(sample)
      File "F:\automatic1111\stable-diffusion-webui\repositories\midas\midas\dpt_depth.py", line 166, in forward
        return super().forward(x).squeeze(dim=1)
      File "F:\automatic1111\stable-diffusion-webui\repositories\midas\midas\dpt_depth.py", line 114, in forward
        layers = self.forward_transformer(self.pretrained, x)
      File "F:\automatic1111\stable-diffusion-webui\repositories\midas\midas\backbones\beit.py", line 15, in forward_beit
        return forward_adapted_unflatten(pretrained, x, "forward_features")
      File "F:\automatic1111\stable-diffusion-webui\repositories\midas\midas\backbones\utils.py", line 86, in forward_adapted_unflatten
        exec(f"glob = pretrained.model.{function_name}(x)")
      File "<string>", line 1, in <module>
      File "F:\automatic1111\stable-diffusion-webui\repositories\midas\midas\backbones\beit.py", line 125, in beit_forward_features
        x = blk(x, resolution, shared_rel_pos_bias=rel_pos_bias)
      File "F:\automatic1111\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "F:\automatic1111\stable-diffusion-webui\repositories\midas\midas\backbones\beit.py", line 102, in block_forward
        x = x + self.drop_path(self.gamma_1 * self.attn(self.norm1(x), resolution,
      File "F:\automatic1111\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1614, in __getattr__
        raise AttributeError("'{}' object has no attribute '{}'".format(
    AttributeError: 'Block' object has no attribute 'drop_path'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.