mirror of
https://github.com/Sygil-Dev/sygil-webui.git
synced 2024-12-14 22:13:41 +03:00
img2img fixes
This commit is contained in:
parent
bf08b617d4
commit
e66eddc621
1
.gitignore
vendored
1
.gitignore
vendored
@ -54,6 +54,7 @@ condaenv.*.requirements.txt
|
||||
/custom-conda-path.txt
|
||||
/src/*
|
||||
/outputs/*
|
||||
/models/*
|
||||
/log/**/*.png
|
||||
/log/log.csv
|
||||
/flagged/*
|
||||
|
@ -33,9 +33,9 @@ dependencies:
|
||||
- facexlib>=0.2.3
|
||||
- python-slugify>=6.1.2
|
||||
- streamlit>=1.12.2
|
||||
- taming-transformers>=0.0.1
|
||||
- openai-clip>=1.0.1
|
||||
- gfpgan>=1.3.5
|
||||
- realesrgan>=0.2.5.0
|
||||
- -e git+https://github.com/CompVis/taming-transformers#egg=taming-transformers
|
||||
- -e git+https://github.com/openai/CLIP#egg=clip
|
||||
- -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN
|
||||
- -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan
|
||||
- -e git+https://github.com/hlky/k-diffusion-sd#egg=k_diffusion
|
||||
- -e .
|
||||
- -e .
|
@ -161,11 +161,11 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
|
||||
with gr.Tabs():
|
||||
with gr.TabItem("Img2Img Input"):
|
||||
#gr.Markdown('#### Img2Img Input')
|
||||
img2img_image_editor = gr.Image(value=sample_img2img, source="upload", interactive=True,
|
||||
img2img_image_mask = gr.Image(value=sample_img2img, source="upload", interactive=False,
|
||||
type="pil", tool="select", elem_id="img2img_editor",
|
||||
image_mode="RGBA")
|
||||
img2img_image_mask = gr.Image(value=sample_img2img, source="upload", interactive=True,
|
||||
type="pil", tool="sketch", visible=False,
|
||||
image_mode="RGBA", visible=False)
|
||||
img2img_image_editor = gr.Image(value=sample_img2img, source="upload", interactive=True,
|
||||
type="pil", tool="sketch", visible=True,
|
||||
elem_id="img2img_mask")
|
||||
|
||||
with gr.TabItem("Img2Img Mask Input"):
|
||||
@ -176,10 +176,10 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
|
||||
with gr.TabItem("Editor Options"):
|
||||
with gr.Row():
|
||||
img2img_image_editor_mode = gr.Radio(choices=["Mask", "Crop", "Uncrop"], label="Image Editor Mode",
|
||||
value="Crop", elem_id='edit_mode_select')
|
||||
img2img_mask = gr.Radio(choices=["Keep masked area", "Regenerate only masked area", "Resize and regenerate only masked area"],
|
||||
value="Mask", elem_id='edit_mode_select', visible=False)
|
||||
img2img_mask = gr.Radio(choices=["Keep masked area", "Regenerate only masked area"],
|
||||
label="Mask Mode", type="index",
|
||||
value=img2img_mask_modes[img2img_defaults['mask_mode']], visible=False)
|
||||
value=img2img_mask_modes[img2img_defaults['mask_mode']], visible=True)
|
||||
|
||||
img2img_mask_blur_strength = gr.Slider(minimum=1, maximum=10, step=1,
|
||||
label="How much blurry should the mask be? (to avoid hard edges)",
|
||||
@ -188,7 +188,7 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
|
||||
img2img_resize = gr.Radio(label="Resize mode",
|
||||
choices=["Just resize", "Crop and resize", "Resize and fill"],
|
||||
type="index",
|
||||
value=img2img_resize_modes[img2img_defaults['resize_mode']])
|
||||
value=img2img_resize_modes[img2img_defaults['resize_mode']], visible=False)
|
||||
|
||||
img2img_painterro_btn = gr.Button("Advanced Editor")
|
||||
with gr.TabItem("Hints"):
|
||||
@ -323,16 +323,16 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
|
||||
|
||||
def generate(*args):
|
||||
args_list = list(args)
|
||||
init_info_mask = args_list[3]
|
||||
init_info_mask = args_list[2]
|
||||
# Get the mask input and remove it from the list
|
||||
mask_input = args_list[18]
|
||||
del args_list[18]
|
||||
mask_input = args_list[-1]
|
||||
del args_list[-1]
|
||||
|
||||
# If an external mask is set, use it
|
||||
if mask_input:
|
||||
init_info_mask['mask'] = mask_input
|
||||
|
||||
args_list[3] = init_info_mask
|
||||
args_list[2] = init_info_mask
|
||||
|
||||
# Return the result of img2img
|
||||
return img2img_func(*args_list)
|
||||
|
@ -288,7 +288,7 @@ class JobManager:
|
||||
return []
|
||||
|
||||
try:
|
||||
outputs = job_info.func(*job_info.inputs, job_info=job_info)
|
||||
outputs = job_info.func(*job_info.inputs)
|
||||
except Exception as e:
|
||||
job_info.job_status = f"Error: {e}"
|
||||
print(f"Exception processing job {job_info}: {e}\n{traceback.format_exc()}")
|
||||
|
@ -1442,11 +1442,11 @@ def img2img(prompt: str, image_editor_mode: str, init_info: any, init_info_mask:
|
||||
|
||||
if image_editor_mode == 'Mask':
|
||||
global returned_info
|
||||
init_img = init_info_mask["image"]
|
||||
init_img = init_info["image"]
|
||||
init_img = init_img.convert("RGB")
|
||||
init_img = resize_image(resize_mode, init_img, width, height)
|
||||
image = image.convert("RGB")
|
||||
init_mask = init_info_mask["mask"]
|
||||
init_img = init_img.convert("RGB")
|
||||
init_mask = init_info["mask"]
|
||||
init_mask = resize_image(resize_mode, init_mask, width, height)
|
||||
resize_mask = mask_mode == 2
|
||||
|
||||
|
@ -38,7 +38,6 @@ IF "%CONDA_PATH%"=="" (
|
||||
:foundPath
|
||||
call "%CONDA_PATH%\Scripts\activate.bat"
|
||||
call conda env create -n "%conda_env_name%" -f environment.yaml
|
||||
call conda env update -n "%conda_env_name%" --file environment.yaml --prune
|
||||
call "%CONDA_PATH%\Scripts\activate.bat" "%conda_env_name%"
|
||||
python "%CD%"\scripts\relauncher.py
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user