Comments (3)
Could put a link to a photo that poses a problem? I'll have to check for myself.
The function that adds the mask to the last part is as follows (in imgutils):
def apply_mask(
img: PILImage, p: processing.StableDiffusionProcessing, batch_index: int
) -> PILImage:
"""
Apply mask overlay and color correction to an image if enabled
Args:
img: PIL Image objects.
p : The processing object
batch_index : the batch index
Returns:
PIL Image object
"""
if isinstance(p, processing.StableDiffusionProcessingImg2Img):
if p.inpaint_full_res:
overlays = p.overlay_images
if overlays is None or batch_index >= len(overlays):
return img
overlay: PILImage = overlays[batch_index]
# This is probably the thing that's causing the problem but this is necessary to merge the two images :
overlay = overlay.resize((img.size), resample=Image.Resampling.LANCZOS)
img = img.copy()
img.paste(overlay, (0, 0), overlay)
return img
img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
if p.color_corrections is not None and batch_index < len(p.color_corrections):
img = processing.apply_color_correction(
p.color_corrections[batch_index], img
)
return img
I changed the title of the issue to be a little less dramatic ;) Even if I recognize that the problem is painful. My hunch is that the resize part is not suitable. But we need to find a solution to do this better.
from sd-webui-faceswaplab.
It seems that resizing is not always necessary. You could try that :
def apply_mask(
img: PILImage, p: processing.StableDiffusionProcessing, batch_index: int
) -> PILImage:
"""
Apply mask overlay and color correction to an image if enabled
Args:
img: PIL Image objects.
p : The processing object
batch_index : the batch index
Returns:
PIL Image object
"""
if isinstance(p, processing.StableDiffusionProcessingImg2Img):
if p.inpaint_full_res:
overlays = p.overlay_images
if overlays is None or batch_index >= len(overlays):
return img
overlay: PILImage = overlays[batch_index]
logger.debug("Overlay size %s, Image size %s", overlay.size, img.size)
if overlay.size != img.size :
overlay = overlay.resize((img.size), resample=Image.Resampling.LANCZOS)
img = img.copy()
img.paste(overlay, (0, 0), overlay)
return img
img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
if p.color_corrections is not None and batch_index < len(p.color_corrections):
img = processing.apply_color_correction(
p.color_corrections[batch_index], img
)
return img
I wonder if resizing is necessary only when the image dimensions are not exactly multiples of 16. I'd had bugs when I didn't resize. That's why I did it without thinking too much about it. I don't use a lot of hd images.
from sd-webui-faceswaplab.
Based on my tests, version 1.2.0 should solve this problem.
from sd-webui-faceswaplab.
Related Issues (20)
- Can't see faceswap in the Automatic1111 UI HOT 2
- Broken model download link
- Future warning 'rcond' parametr
- Pytorch and Torchvision incompatibility in Ubuntu
- It is not working HOT 3
- Cannot load faceswap model in webui-forge HOT 3
- Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given HOT 20
- Change only the target face in an existing image
- FaceSwapLab - ERROR - Conversion failed max() arg is an empty sequence
- ERROR - Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given HOT 20
- Please delete sorry
- failed to install in automatic1111 HOT 1
- img2img -> Inpaint -> dont work HOT 11
- How do I build a checkpoint with multiple angles of a face? HOT 2
- img2img not saving batch images into output directory HOT 3
- Does not work on Automatic1111 HOT 6
- Extension does not respect stable-diffusion-webui `--data-dir` option
- Documentation for API?
- Extension doesnt work on Webforge anymore for 2 days now HOT 7
- txt2img not working only blend face img2img HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sd-webui-faceswaplab.