Merge branch 'master' into img2img2-color-correction
This commit is contained in:
commit
21a375e6b2
4 changed files with 22 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
import math
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from PIL import Image, ImageOps, ImageChops
|
||||
|
||||
from modules.processing import Processed, StableDiffusionProcessingImg2Img, process_images
|
||||
from modules.shared import opts, state
|
||||
|
@ -18,7 +18,9 @@ def img2img(prompt: str, init_img, init_img_with_mask, steps: int, sampler_index
|
|||
|
||||
if is_inpaint:
|
||||
image = init_img_with_mask['image']
|
||||
mask = init_img_with_mask['mask']
|
||||
alpha_mask = ImageOps.invert(image.split()[-1]).convert('L').point(lambda x: 255 if x > 0 else 0, mode='1')
|
||||
mask = ImageChops.lighter(alpha_mask, init_img_with_mask['mask'].convert('L')).convert('RGBA')
|
||||
image = image.convert('RGB')
|
||||
else:
|
||||
image = init_img
|
||||
mask = None
|
||||
|
|
|
@ -323,7 +323,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||
with gr.Group():
|
||||
switch_mode = gr.Radio(label='Mode', elem_id="img2img_mode", choices=['Redraw whole image', 'Inpaint a part of image', 'Loopback', 'SD upscale'], value='Redraw whole image', type="index", show_label=False)
|
||||
init_img = gr.Image(label="Image for img2img", source="upload", interactive=True, type="pil")
|
||||
init_img_with_mask = gr.Image(label="Image for inpainting with mask", elem_id="img2maskimg", source="upload", interactive=True, type="pil", tool="sketch", visible=False)
|
||||
init_img_with_mask = gr.Image(label="Image for inpainting with mask", elem_id="img2maskimg", source="upload", interactive=True, type="pil", tool="sketch", visible=False, image_mode="RGBA")
|
||||
resize_mode = gr.Radio(label="Resize mode", show_label=False, choices=["Just resize", "Crop and resize", "Resize and fill"], type="index", value="Just resize")
|
||||
|
||||
steps = gr.Slider(minimum=1, maximum=150, step=1, label="Sampling Steps", value=20)
|
||||
|
|
16
script.js
16
script.js
|
@ -172,3 +172,19 @@ function submit(){
|
|||
}
|
||||
return res
|
||||
}
|
||||
|
||||
window.addEventListener('paste', e => {
|
||||
const files = e.clipboardData.files;
|
||||
if (!files || files.length !== 1) {
|
||||
return;
|
||||
}
|
||||
if (!['image/png', 'image/gif', 'image/jpeg'].includes(files[0].type)) {
|
||||
return;
|
||||
}
|
||||
[...gradioApp().querySelectorAll('input[type=file][accept="image/x-png,image/gif,image/jpeg"]')]
|
||||
.filter(input => !input.matches('.\\!hidden input[type=file]'))
|
||||
.forEach(input => {
|
||||
input.files = files;
|
||||
input.dispatchEvent(new Event('change'))
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ echo Unable to create venv in directory %VENV_DIR%
|
|||
goto :show_stdout_stderr
|
||||
|
||||
:activate_venv
|
||||
set PYTHON=%~dp0%VENV_DIR%\Scripts\Python.exe
|
||||
set PYTHON="%~dp0%VENV_DIR%\Scripts\Python.exe"
|
||||
%PYTHON% --version
|
||||
echo venv %PYTHON%
|
||||
goto :install_torch
|
||||
|
|
Loading…
Reference in a new issue