parent
c745fa2911
commit
a93e04ea13
@ -43,6 +43,7 @@
|
|||||||
### 0.6.1 <sub><sup>BETA3
|
### 0.6.1 <sub><sup>BETA3
|
||||||
|
|
||||||
- 'Force Upscale' option inside the 'Upscale' tab: ReActor will run the Upscaler even if there's no face is detected (FR https://github.com/Gourieff/sd-webui-reactor/issues/116)
|
- 'Force Upscale' option inside the 'Upscale' tab: ReActor will run the Upscaler even if there's no face is detected (FR https://github.com/Gourieff/sd-webui-reactor/issues/116)
|
||||||
|
- ReActor shows filenames of source images in-process when the multiple images mode or the folder mode (random as well) is selected
|
||||||
|
|
||||||
### 0.6.1 <sub><sup>BETA2
|
### 0.6.1 <sub><sup>BETA2
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
### 0.6.1 <sub><sup>BETA3
|
### 0.6.1 <sub><sup>BETA3
|
||||||
|
|
||||||
- Опция 'Force Upscale' внутри вкладки 'Upscale': апскейл выполнится, даже если не было обнаружено ни одного лица (FR https://github.com/Gourieff/sd-webui-reactor/issues/116)
|
- Опция 'Force Upscale' внутри вкладки 'Upscale': апскейл выполнится, даже если не было обнаружено ни одного лица (FR https://github.com/Gourieff/sd-webui-reactor/issues/116)
|
||||||
|
- Отображение имён файлов используемых изображений, когда выбрано несколько изображений или папка (а также режим случайного изображения)
|
||||||
|
|
||||||
### 0.6.1 <sub><sup>BETA2
|
### 0.6.1 <sub><sup>BETA2
|
||||||
|
|
||||||
|
|||||||
@ -238,7 +238,11 @@ class FaceSwapScript(scripts.Script):
|
|||||||
if ((self.source is not None or self.source_imgs is not None) and self.select_source == 0) or ((self.face_model is not None and self.face_model != "None") and self.select_source == 1) or ((self.source_folder is not None and self.source_folder != "") and self.select_source == 2):
|
if ((self.source is not None or self.source_imgs is not None) and self.select_source == 0) or ((self.face_model is not None and self.face_model != "None") and self.select_source == 1) or ((self.source_folder is not None and self.source_folder != "") and self.select_source == 2):
|
||||||
logger.debug("*** Log patch")
|
logger.debug("*** Log patch")
|
||||||
apply_logging_patch(console_logging_level)
|
apply_logging_patch(console_logging_level)
|
||||||
|
|
||||||
if isinstance(p, StableDiffusionProcessingImg2Img) and self.swap_in_source:
|
if isinstance(p, StableDiffusionProcessingImg2Img) and self.swap_in_source:
|
||||||
|
|
||||||
|
logger.debug("*** Check process")
|
||||||
|
|
||||||
logger.status("Working: source face index %s, target face index %s", self.source_faces_index, self.faces_index)
|
logger.status("Working: source face index %s, target face index %s", self.source_faces_index, self.faces_index)
|
||||||
|
|
||||||
for i in range(len(p.init_images)):
|
for i in range(len(p.init_images)):
|
||||||
@ -279,7 +283,7 @@ class FaceSwapScript(scripts.Script):
|
|||||||
def postprocess(self, p: StableDiffusionProcessing, processed: Processed, *args):
|
def postprocess(self, p: StableDiffusionProcessing, processed: Processed, *args):
|
||||||
if self.enable:
|
if self.enable:
|
||||||
|
|
||||||
logger.debug("*** Check postprocess")
|
logger.debug("*** Check postprocess - before IF")
|
||||||
|
|
||||||
reset_messaged()
|
reset_messaged()
|
||||||
if check_process_halt():
|
if check_process_halt():
|
||||||
@ -287,6 +291,8 @@ class FaceSwapScript(scripts.Script):
|
|||||||
|
|
||||||
if self.save_original or ((self.select_source == 2 and self.source_folder is not None and self.source_folder != "") or (self.select_source == 0 and self.source_imgs is not None and self.source is None)):
|
if self.save_original or ((self.select_source == 2 and self.source_folder is not None and self.source_folder != "") or (self.select_source == 0 and self.source_imgs is not None and self.source is None)):
|
||||||
|
|
||||||
|
logger.debug("*** Check postprocess - after IF")
|
||||||
|
|
||||||
postprocess_run: bool = True
|
postprocess_run: bool = True
|
||||||
|
|
||||||
orig_images : List[Image.Image] = processed.images[processed.index_of_first_image:]
|
orig_images : List[Image.Image] = processed.images[processed.index_of_first_image:]
|
||||||
@ -373,6 +379,21 @@ class FaceSwapScript(scripts.Script):
|
|||||||
|
|
||||||
processed.images = result_images
|
processed.images = result_images
|
||||||
# processed.infotexts = result_info
|
# processed.infotexts = result_info
|
||||||
|
|
||||||
|
elif self.select_source == 0 and self.source is not None and self.source_imgs is not None:
|
||||||
|
|
||||||
|
logger.debug("*** Check postprocess - after ELIF")
|
||||||
|
|
||||||
|
if self.result is not None:
|
||||||
|
orig_infotexts : List[str] = processed.infotexts[processed.index_of_first_image:]
|
||||||
|
processed.images = [self.result]
|
||||||
|
try:
|
||||||
|
img_path = save_image(self.result, p.outpath_samples, "", p.all_seeds[0], p.all_prompts[0], "png", info=orig_infotexts[0], p=p, suffix="")
|
||||||
|
except:
|
||||||
|
logger.error("Cannot save a result image - please, check SD WebUI Settings (Saving and Paths)")
|
||||||
|
else:
|
||||||
|
logger.error("Cannot create a result image")
|
||||||
|
|
||||||
|
|
||||||
def postprocess_batch(self, p, *args, **kwargs):
|
def postprocess_batch(self, p, *args, **kwargs):
|
||||||
if self.enable and not self.save_original:
|
if self.enable and not self.save_original:
|
||||||
@ -392,7 +413,7 @@ class FaceSwapScript(scripts.Script):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# if (self.source is not None and self.select_source == 0) or ((self.face_model is not None and self.face_model != "None") and self.select_source == 1):
|
# if (self.source is not None and self.select_source == 0) or ((self.face_model is not None and self.face_model != "None") and self.select_source == 1):
|
||||||
logger.status("Working: source face index %s, target face index %s", self.source_faces_index, self.faces_index)
|
logger.status("! Working: source face index %s, target face index %s", self.source_faces_index, self.faces_index)
|
||||||
image: Image.Image = script_pp.image
|
image: Image.Image = script_pp.image
|
||||||
result, output, swapped = swap_face(
|
result, output, swapped = swap_face(
|
||||||
self.source,
|
self.source,
|
||||||
@ -413,6 +434,7 @@ class FaceSwapScript(scripts.Script):
|
|||||||
source_imgs = None,
|
source_imgs = None,
|
||||||
random_image = False,
|
random_image = False,
|
||||||
)
|
)
|
||||||
|
self.result = result
|
||||||
try:
|
try:
|
||||||
pp = scripts_postprocessing.PostprocessedImage(result)
|
pp = scripts_postprocessing.PostprocessedImage(result)
|
||||||
pp.info = {}
|
pp.info = {}
|
||||||
@ -575,6 +597,9 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing):
|
|||||||
|
|
||||||
logger.debug("We're here: process() 2")
|
logger.debug("We're here: process() 2")
|
||||||
|
|
||||||
|
if self.source is not None and self.select_source == 0:
|
||||||
|
self.source_imgs = None
|
||||||
|
|
||||||
apply_logging_patch(self.console_logging_level)
|
apply_logging_patch(self.console_logging_level)
|
||||||
logger.status("Working: source face index %s, target face index %s", self.source_faces_index, self.faces_index)
|
logger.status("Working: source face index %s, target face index %s", self.source_faces_index, self.faces_index)
|
||||||
# if self.select_source != 2:
|
# if self.select_source != 2:
|
||||||
|
|||||||
@ -209,14 +209,27 @@ def get_model_names(get_models):
|
|||||||
return names
|
return names
|
||||||
|
|
||||||
def get_images_from_folder(path: str):
|
def get_images_from_folder(path: str):
|
||||||
images_path = os.path.join(path, "*")
|
files_path = os.path.join(path, "*")
|
||||||
images = glob.glob(images_path)
|
files = glob.glob(files_path)
|
||||||
return [Image.open(x) for x in images if x.endswith(('jpg', 'png', 'jpeg', 'webp', 'bmp'))]
|
images = []
|
||||||
|
images_names = []
|
||||||
|
for x in files:
|
||||||
|
if x.endswith(('jpg', 'png', 'jpeg', 'webp', 'bmp')):
|
||||||
|
images.append(Image.open(x))
|
||||||
|
images_names.append(os.path.basename(x))
|
||||||
|
return images,images_names
|
||||||
|
# return [Image.open(x) for x in images if x.endswith(('jpg', 'png', 'jpeg', 'webp', 'bmp'))],[os.path.basename(x) for x in images if x.endswith(('jpg', 'png', 'jpeg', 'webp', 'bmp'))]
|
||||||
|
|
||||||
def get_random_image_from_folder(path: str):
|
def get_random_image_from_folder(path: str):
|
||||||
images = get_images_from_folder(path)
|
images,names = get_images_from_folder(path)
|
||||||
random_image_index = random.randint(0, len(images) - 1)
|
random_image_index = random.randint(0, len(images) - 1)
|
||||||
return [images[random_image_index]]
|
return [images[random_image_index]],[names[random_image_index]]
|
||||||
|
|
||||||
def get_images_from_list(imgs: List):
|
def get_images_from_list(imgs: List):
|
||||||
return [Image.open(os.path.abspath(x.name)) for x in imgs]
|
images = []
|
||||||
|
images_names = []
|
||||||
|
for x in imgs:
|
||||||
|
images.append(Image.open(os.path.abspath(x.name)))
|
||||||
|
images_names.append(os.path.basename(x.name))
|
||||||
|
return images,images_names
|
||||||
|
# return [Image.open(os.path.abspath(x.name)) for x in imgs],[os.path.basename(x.name) for x in imgs]
|
||||||
|
|||||||
@ -380,10 +380,10 @@ def swap_face(
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
if random_image and select_source == 2:
|
if random_image and select_source == 2:
|
||||||
source_images = get_random_image_from_folder(source_folder)
|
source_images,source_images_names = get_random_image_from_folder(source_folder)
|
||||||
logger.status("Processing with Random Image from the folder")
|
logger.status(f"Processing with Random Image from the folder: {source_images_names[0]}")
|
||||||
else:
|
else:
|
||||||
source_images = get_images_from_folder(source_folder) if select_source == 2 else get_images_from_list(source_imgs)
|
source_images,source_images_names = get_images_from_folder(source_folder) if select_source == 2 else get_images_from_list(source_imgs)
|
||||||
|
|
||||||
if len(source_images) > 0:
|
if len(source_images) > 0:
|
||||||
source_img_ff = []
|
source_img_ff = []
|
||||||
@ -412,15 +412,15 @@ def swap_face(
|
|||||||
logger.info("(Image %s) Source Image the Same? %s", i, source_image_same)
|
logger.info("(Image %s) Source Image the Same? %s", i, source_image_same)
|
||||||
|
|
||||||
if len(SOURCE_FACES_LIST) == 0:
|
if len(SOURCE_FACES_LIST) == 0:
|
||||||
logger.status(f"Analyzing Source Image {i}...")
|
logger.status(f"Analyzing Source Image {i}: {source_images_names[i]}...")
|
||||||
source_faces = analyze_faces(source_image)
|
source_faces = analyze_faces(source_image)
|
||||||
SOURCE_FACES_LIST = [source_faces]
|
SOURCE_FACES_LIST = [source_faces]
|
||||||
elif len(SOURCE_FACES_LIST) == i and not source_image_same:
|
elif len(SOURCE_FACES_LIST) == i and not source_image_same:
|
||||||
logger.status(f"Analyzing Source Image {i}...")
|
logger.status(f"Analyzing Source Image {i}: {source_images_names[i]}...")
|
||||||
source_faces = analyze_faces(source_image)
|
source_faces = analyze_faces(source_image)
|
||||||
SOURCE_FACES_LIST.append(source_faces)
|
SOURCE_FACES_LIST.append(source_faces)
|
||||||
elif len(SOURCE_FACES_LIST) != i and not source_image_same:
|
elif len(SOURCE_FACES_LIST) != i and not source_image_same:
|
||||||
logger.status(f"Analyzing Source Image {i}...")
|
logger.status(f"Analyzing Source Image {i}: {source_images_names[i]}...")
|
||||||
source_faces = analyze_faces(source_image)
|
source_faces = analyze_faces(source_image)
|
||||||
SOURCE_FACES_LIST[i] = source_faces
|
SOURCE_FACES_LIST[i] = source_faces
|
||||||
elif source_image_same:
|
elif source_image_same:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user