mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
Fooocus mask enhance, mask upload and invert.蒙版增强功能,上传蒙版、反转手涂蒙版 (#1645)
* Update webui.py Added a mask upload interface.添加蒙版上传界面。 * Add mask upload feature Add mask upload feature.添加蒙版上传功能。 * Add mask upload feature Add mask upload feature.添加蒙版上传功能。 * Try to fix the problem when drawing mates with external enrichment. Swap the judgment criteria and try to fix the problem when drawing mates with external enrichment. 调换判断条件,尝试修复和外部扩充绘制配合时出现的问题 * 修改注释 * 修改注释 * Update readme.md 更新日志 * Add mask upload check box, Add check box, default does not show mask upload box, check it and then show it. 添加复选框,默认不显示蒙版上传框,勾选后再显示。 * back to normal 还原 * Try adding a mask inversion feature Try adding a mask inversion feature. 尝试添加蒙版反转功能。 增加一个复选框来决定是否将蒙版反转。 * Try adding a mask inversion feature Try adding a mask inversion feature. 尝试添加蒙版反转功能。 增加一个复选框来决定是否将蒙版反转。 * Fixed word errors * Fix the words of the description
This commit is contained in:
+31
-1
@@ -22,6 +22,12 @@ def worker():
|
||||
import shared
|
||||
import random
|
||||
import copy
|
||||
|
||||
# xhoxye4
|
||||
# 导入 OpenCV 库
|
||||
import cv2
|
||||
# xhoxye4
|
||||
|
||||
import modules.default_pipeline as pipeline
|
||||
import modules.core as core
|
||||
import modules.flags as flags
|
||||
@@ -138,6 +144,14 @@ def worker():
|
||||
uov_input_image = args.pop()
|
||||
outpaint_selections = args.pop()
|
||||
inpaint_input_image = args.pop()
|
||||
|
||||
# xhoxye5
|
||||
# 接收参数
|
||||
inpaint_mask_image = args.pop()
|
||||
inpaint_mask_image_checkbox = args.pop()
|
||||
invert_mask_checkbox = args.pop()
|
||||
# xhoxye5
|
||||
|
||||
inpaint_additional_prompt = args.pop()
|
||||
|
||||
cn_tasks = {x: [] for x in flags.ip_list}
|
||||
@@ -273,7 +287,23 @@ def worker():
|
||||
current_tab == 'ip' and advanced_parameters.mixing_image_prompt_and_inpaint)) \
|
||||
and isinstance(inpaint_input_image, dict):
|
||||
inpaint_image = inpaint_input_image['image']
|
||||
inpaint_mask = inpaint_input_image['mask'][:, :, 0]
|
||||
|
||||
# xhoxye6
|
||||
#inpaint_mask = inpaint_input_image['mask'][:, :, 0]
|
||||
# use uploaded inpaint mask image, if not brush for inpaint.
|
||||
# 如果没有手涂蒙版,则使用上传蒙版,并缩放。调换判断条件,尝试修复和外部扩充绘制配合时出现的问题.
|
||||
# 添加反转手涂蒙版的判断
|
||||
if inpaint_mask_image_checkbox and not np.any(inpaint_input_image['mask'] == [255, 255, 255]) and inpaint_mask_image is not None:
|
||||
inpaint_height, inpaint_width = inpaint_image.shape[:2]
|
||||
resized_mask_image = cv2.resize(inpaint_mask_image, (inpaint_width, inpaint_height))
|
||||
|
||||
inpaint_mask = resized_mask_image[:, :, 0]
|
||||
else:
|
||||
inpaint_mask = inpaint_input_image['mask'][:, :, 0]
|
||||
if invert_mask_checkbox:
|
||||
inpaint_mask = np.invert(inpaint_mask)
|
||||
# xhoxye6
|
||||
|
||||
inpaint_image = HWC3(inpaint_image)
|
||||
if isinstance(inpaint_image, np.ndarray) and isinstance(inpaint_mask, np.ndarray) \
|
||||
and (np.any(inpaint_mask > 127) or len(outpaint_selections) > 0):
|
||||
|
||||
Reference in New Issue
Block a user